Beispiel #1
0
def test_raise_for_status_does_not_raises_exception() -> None:
    contents = b"downloaded"
    resp = MockResponse(contents)
    resp.status_code = 201
    resp.url = "http://www.example.com/whatever.tgz"
    resp.reason = "No error"
    raise_for_status(resp)
Beispiel #2
0
def test_raise_for_status_does_not_raises_exception():
    contents = b'downloaded'
    resp = MockResponse(contents)
    resp.status_code = 201
    resp.url = "http://www.example.com/whatever.tgz"
    resp.reason = "No error"
    return_value = raise_for_status(resp)
    assert return_value is None
Beispiel #3
0
def test_raise_for_status_raises_exception(status_code, error_type):
    contents = b'downloaded'
    resp = MockResponse(contents)
    resp.status_code = status_code
    resp.url = "http://www.example.com/whatever.tgz"
    resp.reason = "Network Error"
    with pytest.raises(NetworkConnectionError) as exc:
        raise_for_status(resp)
        assert str(exc.info) == (
            "{} {}: Network Error for url:"
            " http://www.example.com/whatever.tgz".format(
                status_code, error_type)
        )