def test_errors(self, event_loop): client = MockAsyncClient( snug.Response( 200, json.dumps({ "data": { "foo": 4 }, "errors": [{ "message": "foo" }] }).encode(), )) future = quiz.execute_async( "my query", url="https://my.url/api", client=client, auth=token_auth("foo"), ) with pytest.raises(quiz.ErrorResponse) as exc: event_loop.run_until_complete(future) assert exc.value == quiz.ErrorResponse({"foo": 4}, [{ "message": "foo" }])
def test_errors_without_data(self): client = MockClient( snug.Response( 200, json.dumps({ 'errors': [{ 'message': 'foo' }] }).encode())) with pytest.raises(quiz.ErrorResponse) as exc: quiz.execute('my query', url='https://my.url/api', client=client, auth=token_auth('foo')) assert exc.value == quiz.ErrorResponse({}, [{'message': 'foo'}])
def test_errors_without_data(self): client = MockClient( snug.Response( 200, json.dumps({ "errors": [{ "message": "foo" }] }).encode())) with pytest.raises(quiz.ErrorResponse) as exc: quiz.execute( "my query", url="https://my.url/api", client=client, auth=token_auth("foo"), ) assert exc.value == quiz.ErrorResponse({}, [{"message": "foo"}])
def test_errors(self, event_loop): client = MockClient( snug.Response( 200, json.dumps({ 'data': { 'foo': 4 }, 'errors': [{ 'message': 'foo' }] }).encode())) future = quiz.execute_async('my query', url='https://my.url/api', client=client, auth=token_auth('foo')) with pytest.raises(quiz.ErrorResponse) as exc: event_loop.run_until_complete(future) assert exc.value == quiz.ErrorResponse({'foo': 4}, [{ 'message': 'foo' }])