diff --git a/tests/fixtures/prepare_bucket_fixture.py b/tests/fixtures/prepare_bucket_fixture.py index 242bb796..1b4c2117 100644 --- a/tests/fixtures/prepare_bucket_fixture.py +++ b/tests/fixtures/prepare_bucket_fixture.py @@ -12,27 +12,31 @@ @pytest.fixture(scope="module") -def prepare_bucket(): +def default_bucket_config(): connection_config = BucketFSConnectionConfig( host="localhost", port=6666, user="w", pwd="write", is_https=False ) bucketfs_config = BucketFSConfig( connection_config=connection_config, bucketfs_name="bfsdefault" ) - bucket_config = BucketConfig(bucket_name="default", bucketfs_config=bucketfs_config) + return BucketConfig(bucket_name="default", bucketfs_config=bucketfs_config) + + +@pytest.fixture(scope="module") +def prepare_bucket(default_bucket_config): test_string = "test_string" path_list = ["path/in/bucket/file.txt", "path/file2.txt"] try: for path_in_bucket in path_list: upload.upload_string_to_bucketfs( - bucket_config=bucket_config, + bucket_config=default_bucket_config, bucket_file_path=path_in_bucket, string=test_string, ) - yield bucket_config + yield default_bucket_config finally: for path_in_bucket in path_list: delete_testfile_from_bucketfs( - file_path=path_in_bucket, bucket_config=bucket_config + file_path=path_in_bucket, bucket_config=default_bucket_config ) diff --git a/tests/integration_tests/without_db/test_bucketfs_factory.py b/tests/integration_tests/without_db/test_bucketfs_factory.py index 9ea1ce6a..e8fb586f 100644 --- a/tests/integration_tests/without_db/test_bucketfs_factory.py +++ b/tests/integration_tests/without_db/test_bucketfs_factory.py @@ -2,19 +2,19 @@ from exasol_bucketfs_utils_python.bucketfs_factory import BucketFSFactory -def test_factory_http_default(prepare_bucket): +def test_factory_http_default(default_bucket_config): """ Tests that all operations work with the default varify option if the connection is http. """ - bfs_config = prepare_bucket.bucketfs_config + bfs_config = default_bucket_config.bucketfs_config conn_config = bfs_config.connection_config - url = f'http://{conn_config.host}:{conn_config.port}/{prepare_bucket.bucket_name}/'\ + url = f'http://{conn_config.host}:{conn_config.port}/{default_bucket_config.bucket_name}/'\ f'base_dir;{bfs_config.bucketfs_name}' bfs_location = BucketFSFactory().create_bucketfs_location(url=url, user=conn_config.user, pwd=conn_config.pwd) - file_name = 'geography.fact' + file_name = 'test_factory_http_default/geography.fact' content = 'Munich is the capital of Bavaria' bfs_location.upload_string_to_bucketfs(file_name, content) assert file_name in bfs_location.list_files_in_bucketfs() @@ -24,39 +24,39 @@ def test_factory_http_default(prepare_bucket): assert file_name not in bfs_location.list_files_in_bucketfs() -def test_factory_https_default(prepare_bucket): +def test_factory_https_default(default_bucket_config): """ Tests that the default varify option leads to failure if the connection is https. """ - bfs_config = prepare_bucket.bucketfs_config + bfs_config = default_bucket_config.bucketfs_config conn_config = bfs_config.connection_config - url = f'https://{conn_config.host}:{conn_config.port}/{prepare_bucket.bucket_name}/'\ + url = f'https://{conn_config.host}:{conn_config.port}/{default_bucket_config.bucket_name}/'\ f'base_dir;{bfs_config.bucketfs_name}' bfs_location = BucketFSFactory().create_bucketfs_location(url=url, user=conn_config.user, pwd=conn_config.pwd) - file_name = 'geography.fact' + file_name = 'test_factory_https_default/geography.fact' content = 'Munich is the capital of Bavaria' with pytest.raises(Exception): bfs_location.upload_string_to_bucketfs(file_name, content) -def test_factory_https_not_verify(prepare_bucket): +def test_factory_https_not_verify(default_bucket_config): """ Tests that all operations work with a https connection if the certificate verification is turned off. """ - bfs_config = prepare_bucket.bucketfs_config + bfs_config = default_bucket_config.bucketfs_config conn_config = bfs_config.connection_config - url = f'https://{conn_config.host}:{conn_config.port}/{prepare_bucket.bucket_name}/'\ + url = f'https://{conn_config.host}:{conn_config.port}/{default_bucket_config.bucket_name}/'\ f'base_dir;{bfs_config.bucketfs_name}#false' bfs_location = BucketFSFactory().create_bucketfs_location(url=url, user=conn_config.user, pwd=conn_config.pwd) - file_name = 'geography.fact' + file_name = 'test_factory_https_not_verify/geography.fact' content = 'Munich is the capital of Bavaria' bfs_location.upload_string_to_bucketfs(file_name, content) assert file_name in bfs_location.list_files_in_bucketfs()