def test_invalid_authentication(self, datadir, serve_protected) -> None: with pytest.raises(TemporaryCheckError): NetworkMixin( serve_protected(datadir / "data.txt")[0], 5, username="******", password="******", ).request()
def test_file_url(self) -> None: NetworkMixin("file://" + __file__, 5).request()
def test_exception_404(self, httpserver) -> None: with pytest.raises(TemporaryCheckError): NetworkMixin(httpserver.url_for("/does/not/exist"), timeout=5).request()
def test_authentication(self, datadir, serve_protected) -> None: url, username, password = serve_protected(datadir / "data.txt") NetworkMixin(url, 5, username=username, password=password).request()
def test_requests_exception(self, mocker) -> None: with pytest.raises(TemporaryCheckError): mock_method = mocker.patch("requests.Session.get") mock_method.side_effect = requests.exceptions.ReadTimeout() NetworkMixin("url", timeout=5).request()
def test_smoke(self, datadir, serve_file) -> None: response = NetworkMixin(serve_file(datadir / "data.txt"), timeout=5).request() assert response is not None assert response.text == "iamhere\n"
def test_invalid_authentication(self, stub_auth_server): with pytest.raises(TemporaryCheckError): NetworkMixin(stub_auth_server.resource_address('data.txt'), 5, username='******', password='******').request()
def test_request(self, datadir, serve_file) -> None: reply = NetworkMixin( serve_file(datadir / "xml_with_encoding.xml"), 5, ).request() assert reply is not None assert reply.status_code == 200
def test_authentication(self, stub_auth_server): NetworkMixin(stub_auth_server.resource_address('data.txt'), 5, username='******', password='******').request()
def test_exception_404(self, stub_server): with pytest.raises(TemporaryCheckError): NetworkMixin(stub_server.resource_address('doesnotexist'), timeout=5).request()
def test_smoke(self, stub_server): response = NetworkMixin(stub_server.resource_address('data.txt'), timeout=5).request() assert response is not None assert response.text == 'iamhere\n'
def test_request(self, stub_server): address = stub_server.resource_address('xml_with_encoding.xml') reply = NetworkMixin(address, 5).request() assert reply is not None assert reply.status_code == 200
def test_file_url(self): NetworkMixin('file://' + __file__, 5).request()