diff --git a/tests/components/conftest.py b/tests/components/conftest.py new file mode 100644 index 000000000..d5e06511d --- /dev/null +++ b/tests/components/conftest.py @@ -0,0 +1,31 @@ +from unittest import mock + +import pytest + +from kpops.component_handlers import ComponentHandlers +from kpops.component_handlers.helm_wrapper.model import HelmDiffConfig +from kpops.config import KpopsConfig, TopicNameConfig, set_config +from tests.components import PIPELINE_BASE_DIR + + +@pytest.fixture(autouse=True, scope="module") +def config() -> None: + config = KpopsConfig( + topic_name_config=TopicNameConfig( + default_error_topic_name="${component.type}-error-topic", + default_output_topic_name="${component.type}-output-topic", + ), + kafka_brokers="broker:9092", + helm_diff_config=HelmDiffConfig(), + pipeline_base_dir=PIPELINE_BASE_DIR, + ) + set_config(config) + + +@pytest.fixture(autouse=True, scope="module") +def handlers() -> None: + ComponentHandlers( + schema_handler=mock.AsyncMock(), + connector_handler=mock.AsyncMock(), + topic_handler=mock.AsyncMock(), + ) diff --git a/tests/components/test_kafka_connector.py b/tests/components/test_kafka_connector.py index ad8f26d67..1592d0182 100644 --- a/tests/components/test_kafka_connector.py +++ b/tests/components/test_kafka_connector.py @@ -46,20 +46,14 @@ def connector_config(self) -> KafkaConnectorConfig: ) @pytest.fixture() - def connector( - self, - connector_config: KafkaConnectorConfig, - ) -> KafkaConnector: + def connector(self, connector_config: KafkaConnectorConfig) -> KafkaConnector: return KafkaConnector( # HACK: not supposed to be instantiated, because ABC name=CONNECTOR_NAME, config=connector_config, resetter_namespace=RESETTER_NAMESPACE, ) - def test_connector_config_name_override( - self, - connector: KafkaConnector, - ): + def test_connector_config_name_override(self, connector: KafkaConnector): assert connector.config.name == CONNECTOR_FULL_NAME connector = KafkaConnector( diff --git a/tests/conftest.py b/tests/conftest.py index 5d99a192e..0e23be87c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,12 +7,8 @@ import pytest -from kpops.component_handlers import ComponentHandlers -from kpops.component_handlers.helm_wrapper.model import HelmDiffConfig -from kpops.config import KpopsConfig, TopicNameConfig, set_config from kpops.utils.environment import ENV, Environment from kpops.utils.yaml import load_yaml_file -from tests.components import PIPELINE_BASE_DIR logger = logging.getLogger("faker") logger.setLevel(logging.INFO) # quiet faker locale messages @@ -55,26 +51,3 @@ def custom_components(): yield finally: shutil.rmtree(dst) - - -@pytest.fixture(autouse=True, scope="session") -def config() -> None: - config = KpopsConfig( - topic_name_config=TopicNameConfig( - default_error_topic_name="${component.type}-error-topic", - default_output_topic_name="${component.type}-output-topic", - ), - kafka_brokers="broker:9092", - helm_diff_config=HelmDiffConfig(), - pipeline_base_dir=PIPELINE_BASE_DIR, - ) - set_config(config) - - -@pytest.fixture(autouse=True, scope="session") -def handlers() -> ComponentHandlers: - return ComponentHandlers( - schema_handler=mock.AsyncMock(), - connector_handler=mock.AsyncMock(), - topic_handler=mock.AsyncMock(), - )