From d0438226dab7035785cfd4fe8ca00a01da5b1e03 Mon Sep 17 00:00:00 2001 From: Salomon Popp Date: Tue, 11 Jul 2023 11:16:18 +0200 Subject: [PATCH] Remove workaround for pipeline steps (#276) --- kpops/cli/main.py | 8 +++----- tests/cli/test_pipeline_steps.py | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/kpops/cli/main.py b/kpops/cli/main.py index e1429321f..71d3cc8d3 100644 --- a/kpops/cli/main.py +++ b/kpops/cli/main.py @@ -154,11 +154,9 @@ def filter_component(component: PipelineComponent) -> bool: def get_steps_to_apply( pipeline: Pipeline, steps: str | None ) -> list[PipelineComponent]: - return ( - list(pipeline) - if not steps or steps == '""' # workaround to allow "" as empty value for CI - else filter_steps_to_apply(pipeline, steps=parse_steps(steps)) - ) + if steps: + return filter_steps_to_apply(pipeline, steps=parse_steps(steps)) + return list(pipeline) def reverse_pipeline_steps(pipeline, steps) -> Iterator[PipelineComponent]: diff --git a/tests/cli/test_pipeline_steps.py b/tests/cli/test_pipeline_steps.py index 2e28fc0d9..da9002e3e 100644 --- a/tests/cli/test_pipeline_steps.py +++ b/tests/cli/test_pipeline_steps.py @@ -5,19 +5,25 @@ from kpops.cli.main import get_steps_to_apply from kpops.pipeline_generator.pipeline import Pipeline +PREFIX = "example-prefix-" + @patch("kpops.cli.main.log.info") def tests_filter_steps_to_apply(log_info): @dataclass class TestComponent: name: str - prefix: str = "example-prefix-" + prefix: str = PREFIX + + test_component_1 = TestComponent(PREFIX + "example1") + test_component_2 = TestComponent(PREFIX + "example2") + test_component_3 = TestComponent(PREFIX + "example3") class TestPipeline: components = [ - TestComponent("example-prefix-example1"), - TestComponent("example-prefix-example2"), - TestComponent("example-prefix-example3"), + test_component_1, + test_component_2, + test_component_3, ] def __iter__(self): @@ -27,8 +33,8 @@ def __iter__(self): filtered_steps = get_steps_to_apply(pipeline, steps="example2,example3") assert len(filtered_steps) == 2 - assert TestComponent("example-prefix-example2") in filtered_steps - assert TestComponent("example-prefix-example3") in filtered_steps + assert test_component_2 in filtered_steps + assert test_component_3 in filtered_steps assert log_info.call_count == 2 log_info.assert_any_call("KPOPS_PIPELINE_STEPS is defined.") @@ -41,6 +47,3 @@ def __iter__(self): filtered_steps = get_steps_to_apply(pipeline, steps="") assert len(filtered_steps) == 3 - - filtered_steps = get_steps_to_apply(pipeline, steps='""') - assert len(filtered_steps) == 3