def test_bad_json_status_404(self): """test_asyncclient | bad json non-200 status """ response = FakeResponse('get', 'url', status=404) async def bad_json(*args, **kwargs): raise ValueError("blah") response.json = bad_json session = getFakeSession(response=response) client = newClient(session=session) with self.assertRaises(exceptions.TaskclusterRestFailure): asyncio.get_event_loop().run_until_complete( client._makeHttpRequest('get', 'http://example.com', '{"clientScopes": ["a"]}', {}, session=session) )
def test_bad_json_status_200(self): """test_asyncclient | bad json 200 status """ response = FakeResponse('get', 'url') async def bad_json(*args, **kwargs): raise ValueError("blah") response.json = bad_json session = getFakeSession(response=response) client = newClient(session=session) result = asyncio.get_event_loop().run_until_complete( client._makeHttpRequest('get', 'http://example.com', '{"clientScopes": ["a"]}', {}, session=session) ) self.assertEqual(result, {'response': response})