From 49cd88311a6733721c40996e0e5fb973d5bc678e Mon Sep 17 00:00:00 2001 From: Ramin Gharib Date: Mon, 15 Jul 2024 12:21:56 +0200 Subject: [PATCH] fix tests --- .../streams_bootstrap/producer/producer_app.py | 10 +++------- .../streams_bootstrap/streams/streams_app.py | 6 +++--- tests/components/test_producer_app.py | 2 +- tests/components/test_streams_app.py | 3 ++- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/kpops/components/streams_bootstrap/producer/producer_app.py b/kpops/components/streams_bootstrap/producer/producer_app.py index 2c07a6e0d..5e2d0855e 100644 --- a/kpops/components/streams_bootstrap/producer/producer_app.py +++ b/kpops/components/streams_bootstrap/producer/producer_app.py @@ -31,10 +31,6 @@ def helm_chart(self) -> str: f"{self.repo_config.repository_name}/{AppType.CLEANUP_PRODUCER_APP.value}" ) - @override - async def clean(self, dry_run: bool) -> None: - await super().clean(dry_run) - class ProducerApp(KafkaApp, StreamsBootstrap): """Producer component. @@ -110,10 +106,10 @@ async def destroy(self, dry_run: bool) -> None: self.namespace, self.helm_release_name ) if cluster_values: - release_name = self._cleaner.helm_release_name - self._cleaner.app = self.app.model_validate(cluster_values) - self._cleaner.app.name_override = release_name log.debug("Fetched helm chart values from cluster") + name_override = self._cleaner.helm_name_override + self._cleaner.app = self.app.model_validate(cluster_values) + self._cleaner.app.name_override = name_override await super().destroy(dry_run) diff --git a/kpops/components/streams_bootstrap/streams/streams_app.py b/kpops/components/streams_bootstrap/streams/streams_app.py index 3a78d4221..dec5f3041 100644 --- a/kpops/components/streams_bootstrap/streams/streams_app.py +++ b/kpops/components/streams_bootstrap/streams/streams_app.py @@ -131,10 +131,10 @@ async def destroy(self, dry_run: bool) -> None: self.namespace, self.helm_release_name ) if cluster_values: - release_name = self._cleaner.helm_release_name - self._cleaner.app = self.app.model_validate(cluster_values) - self._cleaner.app.name_override = release_name log.debug("Fetched helm chart values from cluster") + name_override = self._cleaner.helm_name_override + self._cleaner.app = self.app.model_validate(cluster_values) + self._cleaner.app.name_override = name_override await super().destroy(dry_run) diff --git a/tests/components/test_producer_app.py b/tests/components/test_producer_app.py index f26cfcb2f..0628e19b4 100644 --- a/tests/components/test_producer_app.py +++ b/tests/components/test_producer_app.py @@ -393,7 +393,6 @@ def test_get_output_topics( ] @pytest.mark.asyncio() - @pytest.mark.skip("Cannot be tested with only calling clean.") async def test_should_deploy_clean_up_job_with_values_in_cluster_when_clean( self, config: KpopsConfig, @@ -433,6 +432,7 @@ async def test_should_deploy_clean_up_job_with_values_in_cluster_when_clean( }, }, ) + mocker.patch.object(producer_app.helm, "uninstall") mocker.patch.object(producer_app._cleaner.dry_run_handler, "print_helm_diff") mocker.patch.object(producer_app._cleaner.helm, "uninstall") diff --git a/tests/components/test_streams_app.py b/tests/components/test_streams_app.py index 0c37246a7..20897710f 100644 --- a/tests/components/test_streams_app.py +++ b/tests/components/test_streams_app.py @@ -696,7 +696,6 @@ async def test_should_clean_streams_app_and_deploy_clean_up_job_and_delete_clean ) @pytest.mark.asyncio() - @pytest.mark.skip("Cannot be tested with only calling clean.") async def test_should_deploy_clean_up_job_with_values_in_cluster( self, config: KpopsConfig, @@ -745,6 +744,8 @@ async def test_should_deploy_clean_up_job_with_values_in_cluster( }, ) + mocker.patch.object(streams_app.helm, "uninstall") + mock_helm_upgrade_install = mocker.patch.object( streams_app._cleaner.helm, "upgrade_install" )