diff --git a/test/integration/metadata_test.py b/test/integration/metadata_test.py index 83c06bb..8eea2e4 100644 --- a/test/integration/metadata_test.py +++ b/test/integration/metadata_test.py @@ -118,14 +118,14 @@ def test_list_objects(connection): @pytest.mark.metadata def test_list_object_sizes(connection): - expected = [709780] - actual = [ + sizes = [ db_object["MEM_OBJECT_SIZE"] for db_object in connection.meta.list_object_sizes( object_name_pattern="USERS%", object_type_pattern="TABLE" ) ] - assert actual == expected + do_all_objects_have_a_size = all(map(lambda size: size != 0, sizes)) + assert do_all_objects_have_a_size @pytest.mark.metadata diff --git a/test/integration/proxy_test.py b/test/integration/proxy_test.py new file mode 100644 index 0000000..cc542d2 --- /dev/null +++ b/test/integration/proxy_test.py @@ -0,0 +1,69 @@ +import pytest +import pyexasol +import subprocess +import platform + + +@pytest.fixture +def proxy_port(): + yield 8562 + + +@pytest.fixture +def proxy(proxy_port): + os_specific_flags = ["--reuse"] if platform.system() == "Linux" else [] + command = ["pproxy", "-l", f"http://:{proxy_port}/"] + os_specific_flags + pproxy = subprocess.Popen(command) + + yield f"http://127.0.0.1:{proxy_port}" + + pproxy.kill() + + +@pytest.fixture +def proxy_user(): + yield "johndoe" + + +@pytest.fixture +def proxy_password(): + yield "JohndoesPassword" + + +@pytest.fixture +def proxy_with_auth(proxy_port, proxy_user, proxy_password): + os_specific_flags = ["--reuse"] if platform.system() == "Linux" else [] + command = [ + "pproxy", + "-l", + f"http://:{proxy_port}/#{proxy_user}:{proxy_password}", + ] + os_specific_flags + pproxy = subprocess.Popen(command) + + yield f"http://{proxy_user}:{proxy_password}@localhost:{proxy_port}" + + pproxy.kill() + + +@pytest.mark.configuration +def test_connect_through_proxy(dsn, user, password, schema, proxy): + with pyexasol.connect( + dsn=dsn, user=user, password=password, schema=schema, http_proxy=proxy + ) as connection: + result = connection.execute("SELECT 1;") + expected = 1 + actual = result.fetchval() + assert expected == actual + + +@pytest.mark.configuration +def test_connect_through_proxy_with_authentication( + dsn, user, password, schema, proxy_with_auth +): + with pyexasol.connect( + dsn=dsn, user=user, password=password, schema=schema, http_proxy=proxy_with_auth + ) as connection: + result = connection.execute("SELECT 1;") + expected = 1 + actual = result.fetchval() + assert expected == actual