Skip to content

Commit

Permalink
#5 Added language_container_deployer_cli integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsimb committed May 15, 2024
1 parent d18c8c7 commit 012b240
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
11 changes: 5 additions & 6 deletions test/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from pathlib import Path

import pytest
import click
import requests
Expand Down Expand Up @@ -46,11 +44,12 @@ def container_url(container_version) -> str:


@pytest.fixture(scope='session')
def container_path(tmp_path: Path, container_url) -> Path:
def container_path(tmpdir_factory, container_url, container_name) -> str:

slc_path = tmp_path / SLC_NAME
response = requests.get(container_url)
response = requests.get(container_url, allow_redirects=True)
response.raise_for_status()
with slc_path.open('wb') as f:
slc_path = tmpdir_factory.mktemp('container').join(container_name)
slc_path = str(slc_path)
with open(slc_path, 'wb') as f:
f.write(response.content)
return slc_path
8 changes: 4 additions & 4 deletions test/integration/test_language_container_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_language_container_deployer(
connection_factory: Callable[[config.Exasol], ExaConnection],
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
container_path: Path):
container_path: str):
"""
Tests the deployment of a container in one call, including the activation at the System level.
"""
Expand All @@ -48,7 +48,7 @@ def test_language_container_deployer(
deployer = create_container_deployer(language_alias=language_alias,
pyexasol_connection=pyexasol_connection,
bucketfs_config=bucketfs_config)
deployer.run(container_file=container_path, alter_system=True, allow_override=True)
deployer.run(container_file=Path(container_path), alter_system=True, allow_override=True)
new_connection = stack.enter_context(connection_factory(exasol_config))
assert_udf_running(new_connection, language_alias, schema)

Expand Down Expand Up @@ -88,7 +88,7 @@ def test_language_container_deployer_activation_fail(
connection_factory: Callable[[config.Exasol], ExaConnection],
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
container_path: Path,
container_path: str,
container_name: str):
"""
Tests that an attempt to activate a container using alias that already exists
Expand All @@ -104,7 +104,7 @@ def test_language_container_deployer_activation_fail(
deployer = create_container_deployer(language_alias=language_alias,
pyexasol_connection=pyexasol_connection,
bucketfs_config=bucketfs_config)
deployer.run(container_file=container_path, alter_system=True, allow_override=True)
deployer.run(container_file=Path(container_path), alter_system=True, allow_override=True)
new_connection = stack.enter_context(connection_factory(exasol_config))
deployer = create_container_deployer(language_alias=language_alias,
pyexasol_connection=new_connection,
Expand Down
12 changes: 6 additions & 6 deletions test/integration/test_language_container_deployer_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def call_language_definition_deployer_cli(func,
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
language_alias: str,
container_path: Optional[Path] = None,
container_path: Optional[str] = None,
version: Optional[str] = None,
use_ssl_cert_validation: bool = False):
parsed_url = urlparse(bucketfs_config.url)
Expand All @@ -43,13 +43,13 @@ def call_language_definition_deployer_cli(func,
args_list += [
"--no-use-ssl-cert-validation"
]
if version is not None:
if version:
args_list += [
"--version", version,
]
if container_path is not None:
if container_path:
args_list += [
"--container-file", str(container_path),
"--container-file", container_path,
]
runner = CliRunner()
result = runner.invoke(func, args_list)
Expand All @@ -61,7 +61,7 @@ def test_language_container_deployer_cli_with_container_file(
connection_factory: Callable[[config.Exasol], ExaConnection],
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
container_path: Path,
container_path: str,
main_func
):
test_name: str = request.node.name
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_language_container_deployer_cli_with_check_cert(
connection_factory: Callable[[config.Exasol], ExaConnection],
exasol_config: config.Exasol,
bucketfs_config: config.BucketFs,
container_path: Path,
container_path: str,
main_func
):
expected_exception_message = '[SSL: CERTIFICATE_VERIFY_FAILED]'
Expand Down

0 comments on commit 012b240

Please sign in to comment.