def test_unknown_url_no_exception(): # Shouldn't leak any socket or HTTPExceptions response = HttpClientUploader.upload(url="http://nowhere.example.com", data=b"{}", headers=[]) assert type(response) is ping_uploader.RecoverableFailure
def test_500_error(safe_httpserver): safe_httpserver.serve_content(b"", code=500) response = HttpClientUploader.upload(url=safe_httpserver.url, data=b"{}", headers=[]) assert type(response) is ping_uploader.HttpResponse assert 500 == response._status_code assert 1 == len(safe_httpserver.requests)
def test_unknown_scheme(): response = HttpClientUploader.upload(url="ftp://example.com/", data=b"{}", headers=[]) assert type(response) is ping_uploader.UnrecoverableFailure
def test_unknown_url_no_exception(): # Shouldn't leak any socket or HTTPExceptions assert not HttpClientUploader.upload("http://nowhere.example.com", "{}", [])