def test_SignaturesForBugs(self): def mocked_get_bugs(**options): return {"hits": [{"id": "123456789", "signature": "Something"}]} SignaturesByBugs.implementation().get.side_effect = mocked_get_bugs url = reverse('api:model_wrapper', args=('SignaturesByBugs', )) response = self.client.get(url) assert response.status_code == 400 assert response['Content-Type'] == 'application/json; charset=UTF-8' dump = json.loads(response.content) assert dump['errors']['bug_ids'] response = self.client.get(url, { 'bug_ids': '123456789', }) assert response.status_code == 200 dump = json.loads(response.content) assert dump['hits']
def test_SignaturesForBugs(self): def mocked_get_bugs(**options): return { "hits": [ {"id": "123456789", "signature": "Something"} ] } SignaturesByBugs.implementation().get.side_effect = mocked_get_bugs url = reverse('api:model_wrapper', args=('SignaturesByBugs',)) response = self.client.get(url) eq_(response.status_code, 400) eq_(response['Content-Type'], 'application/json; charset=UTF-8') dump = json.loads(response.content) ok_(dump['errors']['bug_ids']) response = self.client.get(url, { 'bug_ids': '123456789', }) eq_(response.status_code, 200) dump = json.loads(response.content) ok_(dump['hits'])