Skip to content

Commit

Permalink
Don't allow --starters with --tools or --example (#3362)
Browse files Browse the repository at this point in the history
Signed-off-by: Merel Theisen <merel.theisen@quantumblack.com>
  • Loading branch information
merelcht committed Nov 30, 2023
1 parent f171617 commit 5292834
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kedro/framework/cli/starters.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ def new( # noqa: PLR0913
"Cannot use the --directory flag without a --starter value."
)

if (selected_tools or example_pipeline) and starter_alias:
raise KedroCliError(
"Cannot use the --starter flag with the --example and/or --tools flag."
)

starters_dict = _get_starters_dict()

if starter_alias in starters_dict:
Expand Down
24 changes: 24 additions & 0 deletions tests/framework/cli/test_starters.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,30 @@ def test_directory_flag_with_starter_alias(self, fake_kedro_cli):
assert result.exit_code != 0
assert "Cannot use the --directory flag with a --starter alias" in result.output

def test_starter_flag_with_tools_flag(self, fake_kedro_cli):
result = CliRunner().invoke(
fake_kedro_cli,
["new", "--tools", "all", "--starter", "spaceflights-pandas"],
input=_make_cli_prompt_input(),
)
assert result.exit_code != 0
assert (
"Cannot use the --starter flag with the --example and/or --tools flag."
in result.output
)

def test_starter_flag_with_example_flag(self, fake_kedro_cli):
result = CliRunner().invoke(
fake_kedro_cli,
["new", "--starter", "spaceflights-pandas", "--example", "no"],
input=_make_cli_prompt_input(),
)
assert result.exit_code != 0
assert (
"Cannot use the --starter flag with the --example and/or --tools flag."
in result.output
)


@pytest.mark.usefixtures("chdir_to_tmp")
class TestToolsAndExampleFromUserPrompts:
Expand Down

0 comments on commit 5292834

Please sign in to comment.