Skip to content

Commit

Permalink
#188 renamed global pytest fixtures (#207)
Browse files Browse the repository at this point in the history
* #188: Renamed global pytest fixtures to avoid name clashes
  • Loading branch information
ckunki authored Nov 5, 2024
1 parent a79d4a9 commit 3fecabc
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 263 deletions.
6 changes: 6 additions & 0 deletions doc/changes/changes_0.1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ Code name:

## Summary

## Bugfixes

* #206: Fixed download URL of SLC from GitHub releases

## Refactorings

* #188: Renamed global pytest fixtures to avoid name clashes
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@


@pytest.fixture(scope="session")
def db_schema_name() -> str:
def itest_db_schema() -> str:
"""
Overrides default fixture from pytest-exasol-extension.
"""
return "TEST_INTEGRATION"


@pytest.fixture(scope="module")
def deployed_scripts(pyexasol_connection, db_schema_name, language_alias) -> None:
def deployed_scripts(pyexasol_connection, itest_db_schema, language_alias) -> None:
save_aaf_query_loop_lua_script()
ScriptsDeployer(
language_alias,
db_schema_name,
itest_db_schema,
pyexasol_connection,
).deploy_scripts()


@pytest.fixture(scope="module")
def database_with_slc(
deployed_scripts,
db_schema_name,
itest_db_schema,
bucketfs_connection_factory,
deployed_slc,
) -> Tuple[str, str]:
bucketfs_connection_factory(BUCKETFS_CONNECTION_NAME, "my-folder")
return BUCKETFS_CONNECTION_NAME, db_schema_name
return BUCKETFS_CONNECTION_NAME, itest_db_schema
44 changes: 22 additions & 22 deletions tests/unit_tests/query_handler/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@


@pytest.fixture
def prefix() -> str:
def tmp_db_obj_prefix() -> str:
return PREFIX


@pytest.fixture
def schema() -> str:
def aaf_pytest_db_schema() -> str:
return SCHEMA


class TestConnection(Connection):
class ConnectionMock(Connection):

@property
def name(self) -> str:
Expand All @@ -41,15 +41,15 @@ def password(self) -> str:


@pytest.fixture
def test_connection() -> Connection:
return TestConnection()
def connection_mock() -> Connection:
return ConnectionMock()


@pytest.fixture
def test_connection_lookup(test_connection) -> ConnectionLookup:
def connection_lookup_mock(connection_mock) -> ConnectionLookup:
def lookup(name: str) -> Connection:
if name == test_connection.name:
return test_connection
if name == connection_mock.name:
return connection_mock
else:
raise KeyError()

Expand All @@ -62,7 +62,7 @@ def sample_mounted_bucket(tmp_path):


@pytest.fixture
def bucketfs_location(sample_mounted_bucket):
def sample_bucketfs_location(sample_mounted_bucket):
return bfs.path.BucketPath("a/b", sample_mounted_bucket)


Expand All @@ -73,25 +73,25 @@ def mocked_temporary_bucketfs_location(tmp_path):


@pytest.fixture
def top_level_query_handler_context(
bucketfs_location: bfs.path.PathLike,
prefix: str,
schema: str,
test_connection_lookup: ConnectionLookup) -> TopLevelQueryHandlerContext:
def top_level_query_handler_context_mock(
sample_bucketfs_location: bfs.path.PathLike,
tmp_db_obj_prefix: str,
aaf_pytest_db_schema: str,
connection_lookup_mock: ConnectionLookup) -> TopLevelQueryHandlerContext:
query_handler_context = TopLevelQueryHandlerContext(
temporary_bucketfs_location=bucketfs_location,
temporary_db_object_name_prefix=prefix,
connection_lookup=test_connection_lookup,
temporary_schema_name=schema
temporary_bucketfs_location=sample_bucketfs_location,
temporary_db_object_name_prefix=tmp_db_obj_prefix,
connection_lookup=connection_lookup_mock,
temporary_schema_name=aaf_pytest_db_schema,
)
return query_handler_context


@pytest.fixture(params=["top", "child"])
def scope_query_handler_context(
top_level_query_handler_context: TopLevelQueryHandlerContext,
def scope_query_handler_context_mock(
top_level_query_handler_context_mock: TopLevelQueryHandlerContext,
request) -> ScopeQueryHandlerContext:
if request.param == "top":
return top_level_query_handler_context
return top_level_query_handler_context_mock
else:
return top_level_query_handler_context.get_child_query_handler_context()
return top_level_query_handler_context_mock.get_child_query_handler_context()
Loading

0 comments on commit 3fecabc

Please sign in to comment.