Exemple #1
0
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)
Exemple #2
0
 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)
Exemple #3
0
 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))
Exemple #4
0
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)
Exemple #5
0
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)