Skip to content

Commit

Permalink
Fix user API test
Browse files Browse the repository at this point in the history
  • Loading branch information
gdude2002 committed Mar 4, 2018
1 parent a331abc commit 6be52b1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ def test_api_user(self):
""" Check insert user """
os.environ['BOT_API_KEY'] = 'abcdefg'
headers = {'X-API-Key': 'abcdefg', 'Content-Type': 'application/json'}
bad_data = json.dumps({'user_id': 1234, 'role': 5678})
good_data = json.dumps([{'user_id': 1234, 'role': 5678}])
single_data = json.dumps({'user_id': 1234, 'role': 5678})
list_data = json.dumps([{'user_id': 1234, 'role': 5678}])

response = self.client.get('/user', app.config['API_SUBDOMAIN'], headers=headers)
self.assertEqual(response.status_code, 405)

response = self.client.post('/user', app.config['API_SUBDOMAIN'], headers=headers, data=bad_data)
self.assertEqual(response.json, {'error_code': 3, 'error_message': 'Incorrect parameters provided'})
response = self.client.post('/user', app.config['API_SUBDOMAIN'], headers=headers, data=single_data)
self.assertTrue("inserted" in response.json)

response = self.client.post('/user', app.config['API_SUBDOMAIN'], headers=headers, data=good_data)
self.assertEqual(True, "inserted" in response.json)
response = self.client.post('/user', app.config['API_SUBDOMAIN'], headers=headers, data=list_data)
self.assertTrue("inserted" in response.json)

def test_api_route_errors(self):
""" Check api route errors """
Expand Down

0 comments on commit 6be52b1

Please sign in to comment.