This commit is contained in:
Martin
2016-06-30 17:31:58 +02:00
parent 032b417e1d
commit 77634ae303
15 changed files with 41 additions and 23 deletions
+9 -5
View File
@@ -36,8 +36,10 @@ class TestEndpoints(flask_testing.TestCase):
self.assert200(response)
def test_create_designer(self):
data = {'name': 'Spider-Man', 'username': 'spiderman', 'territory': 'US', 'currency': 'USD'}
response = self.client.post('/designers/', data=json.dumps(data), content_type='application/json')
data = {'name': 'Spider-Man', 'username': 'spiderman',
'territory': 'US', 'currency': 'USD'}
response = self.client.post(
'/designers/', data=json.dumps(data), content_type='application/json')
self.assertEqual(201, response.status_code)
designer = response.json
self.assertEqual('Spider-Man', designer['name'])
@@ -45,14 +47,16 @@ class TestEndpoints(flask_testing.TestCase):
def test_create_designer_missing_data(self):
data = {}
response = self.client.post('/designers/', data=json.dumps(data), content_type='application/json')
response = self.client.post(
'/designers/', data=json.dumps(data), content_type='application/json')
self.assert400(response)
@patch('api.tasks.esales.update_designer')
def test_update_designer(self, esales_update_designer):
designer = self._add_designer('designer1')
data = {'name': 'test'}
response = self.client.put('/designers/1', data=json.dumps(data), content_type='application/json')
response = self.client.put(
'/designers/1', data=json.dumps(data), content_type='application/json')
self.assertTrue(esales_update_designer.called)
self.assertEqual('test', response.json['name'])
self.assertEqual('test', Designer.query.get(1).name)
self.assertEqual('test', Designer.query.get(1).name)