Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed all method-based session fixtures to class scope #149

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/dl_api_lib_testing/dl_api_lib_testing/dataset_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class DatasetTestBase(ConnectionTestBase, metaclass=abc.ABCMeta):
@abc.abstractmethod
@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def dataset_params(self) -> dict:
raise NotImplementedError

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class BaseCHS3TestClass(BaseConnectionTestClass[FILE_CONN_TV], metaclass=abc.ABC

source_type: ClassVar[DataSourceType]

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def event_loop(self):
"""Avoid spontaneous event loop closes between tests"""
loop = asyncio.get_event_loop()
Expand All @@ -83,28 +83,28 @@ def db_url(self) -> str:
def engine_config(self, db_url: str, engine_params: dict) -> ClickhouseDbEngineConfig:
return ClickhouseDbEngineConfig(url=db_url, engine_params=engine_params)

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def conn_bi_context(self) -> RequestContextInfo:
return RequestContextInfo(tenant=TenantCommon())

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def redis_setting_maker(self) -> RedisSettingMaker:
core_test_config = test_config.CORE_TEST_CONFIG
return core_test_config.get_redis_setting_maker()

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def s3_settings(self) -> S3Settings:
return S3Settings(
ENDPOINT_URL=test_config.S3_ENDPOINT_URL,
ACCESS_KEY_ID=self.connection_settings.ACCESS_KEY_ID,
SECRET_ACCESS_KEY=self.connection_settings.SECRET_ACCESS_KEY,
)

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def task_processor_factory(self) -> TaskProcessorFactory:
return DummyTaskProcessorFactory()

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def conn_sync_service_registry(
self,
conn_bi_context: RequestContextInfo,
Expand All @@ -116,7 +116,7 @@ def conn_sync_service_registry(
task_processor_factory=task_processor_factory,
)

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def conn_async_service_registry(
self,
conn_bi_context: RequestContextInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class TestMSSQLSubselectByView(

raw_sql_level = RawSQLLevel.subselect

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def initial_data_source_spec(self) -> SubselectDataSourceSpec:
dsrc_spec = SubselectDataSourceSpec(
source_type=SOURCE_TYPE_MSSQL_SUBSELECT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class TestOracleSubselectByView(

raw_sql_level = RawSQLLevel.subselect

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def initial_data_source_spec(self) -> SubselectDataSourceSpec:
dsrc_spec = SubselectDataSourceSpec(
source_type=SOURCE_TYPE_ORACLE_SUBSELECT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def check_closing_sql_sessions(self, db: Db) -> Generator[None, None, None]:


class DefaultSyncConnectionExecutorTestSuite(DefaultSyncAsyncConnectionExecutorCheckBase[_CONN_TV], Generic[_CONN_TV]):
@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def conn_exec_factory_async_env(self) -> bool:
return False

Expand Down Expand Up @@ -269,7 +269,7 @@ def test_get_table_schema_info_for_nonexistent_table(


class DefaultAsyncConnectionExecutorTestSuite(DefaultSyncAsyncConnectionExecutorCheckBase[_CONN_TV], Generic[_CONN_TV]):
@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def conn_exec_factory_async_env(self) -> bool:
return True

Expand Down
12 changes: 6 additions & 6 deletions lib/dl_core_testing/dl_core_testing/testcases/service_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ServiceFixtureTextClass(metaclass=abc.ABCMeta):
connection_settings: ClassVar[Optional[ConnectorSettingsBase]] = None
inst_specific_sr_factory: ClassVar[Optional[InstallationSpecificServiceRegistryFactory]] = None

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def conn_us_config(self) -> USConfig:
us_env_config = self.core_test_config.get_us_config()
return USConfig(
Expand All @@ -60,12 +60,12 @@ def conn_us_config(self) -> USConfig:
us_crypto_keys_config=self.core_test_config.get_crypto_keys_config(),
)

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def conn_bi_context(self) -> RequestContextInfo:
bi_context = RequestContextInfo.create_empty()
return bi_context

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def conn_exec_factory_async_env(self) -> bool:
return False

Expand Down Expand Up @@ -101,7 +101,7 @@ def service_registry_factory(
sr_future_ref.fulfill(service_registry)
return service_registry

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def conn_sync_service_registry(
self,
conn_bi_context: RequestContextInfo,
Expand All @@ -111,7 +111,7 @@ def conn_sync_service_registry(
conn_bi_context=conn_bi_context,
)

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def conn_async_service_registry(
self,
conn_bi_context: RequestContextInfo,
Expand All @@ -121,7 +121,7 @@ def conn_async_service_registry(
conn_bi_context=conn_bi_context,
)

@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def conn_default_service_registry(
self,
conn_exec_factory_async_env: bool,
Expand Down
2 changes: 1 addition & 1 deletion terrarium/dl_repmanager/dl_repmanager_tests/unit/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def deployed_repo(repo_src: Path) -> Generator[Path, None, None]:


class RepmanagerTestingBase:
@pytest.fixture(scope="session")
@pytest.fixture(scope="class")
def repo_path(self) -> Generator[Path, None, None]:
with deployed_repo(REPO_PATH) as repo_path:
yield repo_path
Expand Down
Loading