예제 #1
0
 def test_invalid_authentication(self, datadir, serve_protected) -> None:
     with pytest.raises(TemporaryCheckError):
         NetworkMixin(
             serve_protected(datadir / "data.txt")[0],
             5,
             username="******",
             password="******",
         ).request()
예제 #2
0
 def test_file_url(self) -> None:
     NetworkMixin("file://" + __file__, 5).request()
예제 #3
0
 def test_exception_404(self, httpserver) -> None:
     with pytest.raises(TemporaryCheckError):
         NetworkMixin(httpserver.url_for("/does/not/exist"), timeout=5).request()
예제 #4
0
 def test_authentication(self, datadir, serve_protected) -> None:
     url, username, password = serve_protected(datadir / "data.txt")
     NetworkMixin(url, 5, username=username, password=password).request()
예제 #5
0
    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()
예제 #6
0
 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"
예제 #7
0
 def test_invalid_authentication(self, stub_auth_server):
     with pytest.raises(TemporaryCheckError):
         NetworkMixin(stub_auth_server.resource_address('data.txt'),
                      5, username='******', password='******').request()
예제 #8
0
 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
예제 #9
0
 def test_authentication(self, stub_auth_server):
     NetworkMixin(stub_auth_server.resource_address('data.txt'),
                  5, username='******', password='******').request()
예제 #10
0
 def test_exception_404(self, stub_server):
     with pytest.raises(TemporaryCheckError):
         NetworkMixin(stub_server.resource_address('doesnotexist'),
                      timeout=5).request()
예제 #11
0
 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'
예제 #12
0
 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
예제 #13
0
 def test_file_url(self):
     NetworkMixin('file://' + __file__, 5).request()