def test_http_error(): err = quiz.HTTPError( snug.Response(404, content=b"not found!\x00"), snug.Request("POST", "https://my.url/api"), ) assert "not found!\\x00" in str(err) assert "404" in str(err) assert "my.url" in str(err)
def test_http_error(self): err_response = snug.Response(403, b'this is an error!') client = MockClient(err_response) with pytest.raises(quiz.HTTPError) as exc: quiz.execute('my query', url='https://my.url/api', client=client, auth=token_auth('foo')) assert exc.value == quiz.HTTPError(err_response)
def test_http_error(self, mocker): err_response = snug.Response(403, b"this is an error!") client = MockClient(err_response) with pytest.raises(quiz.HTTPError) as exc: quiz.execute( "my query", url="https://my.url/api", client=client, auth=token_auth("foo"), ) assert exc.value == quiz.HTTPError( err_response, client.request.replace(headers=mocker.ANY))
def test_http_error(): err = quiz.HTTPError(snug.Response(404, content=b'not found!\x00')) assert 'not found!\\x00' in str(err) assert '404' in str(err)
def test_http_error(): err = quiz.HTTPError(snug.Response(404, content=b'not found!\x00'), snug.Request('POST', 'https://my.url/api')) assert 'not found!\\x00' in str(err) assert '404' in str(err) assert 'my.url' in str(err)