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

Make e2e tests pull main branch of kedro-starters when using tools #3518

Merged
merged 23 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6cf11bf
attempt to fix mismatch version of kedro-starters and kedro for unit …
SajidAlamQB Jan 16, 2024
c21d850
fix for e2e
SajidAlamQB Jan 17, 2024
637d609
revert unit test changes
SajidAlamQB Jan 17, 2024
68f8a4e
lint
SajidAlamQB Jan 17, 2024
10ba8b3
test with env variables
SajidAlamQB Jan 17, 2024
5e7522e
Merge branch 'main' into run-kedro-starters-main-branch-on-ci
SajidAlamQB Jan 17, 2024
d822a51
Merge branch 'main' into run-kedro-starters-main-branch-on-ci
SajidAlamQB Jan 17, 2024
16147df
make cookiecutter_args fixture on classes
SajidAlamQB Jan 17, 2024
2bc8e76
Update e2e-tests.yml
SajidAlamQB Jan 18, 2024
4fc8839
Update cli_steps.py
SajidAlamQB Jan 18, 2024
bcc9388
Merge branch 'main' into run-kedro-starters-main-branch-on-ci
SajidAlamQB Jan 18, 2024
302976e
simplify e2e test for tools
SajidAlamQB Jan 18, 2024
472e62e
set example_pipeline to "n"
SajidAlamQB Jan 18, 2024
42ff0e3
Merge branch 'main' into run-kedro-starters-main-branch-on-ci
SajidAlamQB Jan 18, 2024
4ddc75a
undo version update for testing
SajidAlamQB Jan 18, 2024
3c45b18
Merge branch 'main' into run-kedro-starters-main-branch-on-ci
SajidAlamQB Jan 18, 2024
f2d4a26
Merge branch 'main' into run-kedro-starters-main-branch-on-ci
SajidAlamQB Jan 18, 2024
b961e71
fix merge
SajidAlamQB Jan 18, 2024
64c6164
lint
SajidAlamQB Jan 18, 2024
95acf99
update check_created_project_structure_from_tools for shortnames
SajidAlamQB Jan 18, 2024
83df5fe
lint
SajidAlamQB Jan 18, 2024
3423081
changes based on review
SajidAlamQB Jan 18, 2024
4fac009
revert exit code change
SajidAlamQB Jan 18, 2024
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
4 changes: 2 additions & 2 deletions features/steps/cli_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def create_config_file_without_starter(context):
def create_config_file_with_tools(context, tools):
"""Behave step to create a temporary config file
(given the existing temp directory) and store it in the context.
It takes a custom tools list and sets example prompt to `y`.
It takes a custom tools list and sets example prompt to `n`.
"""

context.config_file = context.temp_dir / "config.yml"
Expand All @@ -195,7 +195,7 @@ def create_config_file_with_tools(context, tools):
context.package_name = context.project_name.replace("-", "_")
config = {
"tools": tools,
"example_pipeline": "y",
"example_pipeline": "n",
"project_name": context.project_name,
"repo_name": context.project_name,
"output_dir": str(context.temp_dir),
Expand Down
30 changes: 0 additions & 30 deletions features/tools.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,8 @@ Feature: New Kedro project with tools
Given I have prepared a config file with tools "none"
When I run a non-interactive kedro new without starter
Then the expected tool directories and files should be created with "none"
Given I have installed the project dependencies
When I execute the kedro command "run"
Then I should get a successful exit code

Scenario: Create a new Kedro project with all tools except 'viz' and 'pyspark'
Given I have prepared a config file with tools "lint, test, log, docs, data"
When I run a non-interactive kedro new without starter
Then the expected tool directories and files should be created with "lint, test, log, docs, data"
SajidAlamQB marked this conversation as resolved.
Show resolved Hide resolved
Given I have installed the project dependencies
When I execute the kedro command "run"
Then I should get a successful exit code

Scenario: Create a new Kedro project with all tools
Given I have prepared a config file with tools "all"
When I run a non-interactive kedro new without starter
Then the expected tool directories and files should be created with "all"
Given I have installed the project dependencies
When I execute the kedro command "run"
Then I should get a successful exit code

Scenario: Create a new Kedro project with only 'pyspark' tool
Given I have prepared a config file with tools "pyspark"
When I run a non-interactive kedro new without starter
Then the expected tool directories and files should be created with "pyspark"
Given I have installed the project dependencies
When I execute the kedro command "run"
Then I should get a successful exit code

Scenario: Create a new Kedro project with only 'viz' tool
Given I have prepared a config file with tools "viz"
When I run a non-interactive kedro new without starter
Then the expected tool directories and files should be created with "viz"
Given I have installed the project dependencies
When I execute the kedro command "run"
Then I should get a successful exit code
53 changes: 31 additions & 22 deletions tests/framework/cli/test_starters.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ def mock_cookiecutter(mocker):
return mocker.patch("cookiecutter.main.cookiecutter")


@pytest.fixture
def patch_cookiecutter_args(mocker):
mocker.patch(
"kedro.framework.cli.starters._make_cookiecutter_args_and_fetch_template",
side_effect=mock_make_cookiecutter_args_and_fetch_template,
)


def mock_make_cookiecutter_args_and_fetch_template(*args, **kwargs):
cookiecutter_args, starter_path = _make_cookiecutter_args_and_fetch_template(
*args, **kwargs
Expand Down Expand Up @@ -998,7 +1006,7 @@ def test_starter_flag_with_example_flag(self, fake_kedro_cli):
)


@pytest.mark.usefixtures("chdir_to_tmp")
@pytest.mark.usefixtures("chdir_to_tmp", "patch_cookiecutter_args")
class TestToolsAndExampleFromUserPrompts:
@pytest.mark.parametrize(
"tools",
Expand Down Expand Up @@ -1026,13 +1034,7 @@ class TestToolsAndExampleFromUserPrompts:
],
)
@pytest.mark.parametrize("example_pipeline", ["Yes", "No"])
def test_valid_tools_and_example(
self, fake_kedro_cli, tools, example_pipeline, mocker
):
mocker.patch(
"kedro.framework.cli.starters._make_cookiecutter_args_and_fetch_template",
side_effect=mock_make_cookiecutter_args_and_fetch_template,
)
def test_valid_tools_and_example(self, fake_kedro_cli, tools, example_pipeline):
result = CliRunner().invoke(
fake_kedro_cli,
["new"],
Expand Down Expand Up @@ -1137,7 +1139,7 @@ def test_invalid_example(self, fake_kedro_cli, bad_input):
)


@pytest.mark.usefixtures("chdir_to_tmp")
@pytest.mark.usefixtures("chdir_to_tmp", "patch_cookiecutter_args")
class TestToolsAndExampleFromConfigFile:
@pytest.mark.parametrize(
"tools",
Expand Down Expand Up @@ -1167,15 +1169,8 @@ class TestToolsAndExampleFromConfigFile:
],
)
@pytest.mark.parametrize("example_pipeline", ["Yes", "No"])
def test_valid_tools_and_example(
self, fake_kedro_cli, tools, example_pipeline, mocker
):
def test_valid_tools_and_example(self, fake_kedro_cli, tools, example_pipeline):
"""Test project created from config."""
mocker.patch(
"kedro.framework.cli.starters._make_cookiecutter_args_and_fetch_template",
side_effect=mock_make_cookiecutter_args_and_fetch_template,
)

config = {
"tools": tools,
"project_name": "New Kedro Project",
Expand Down Expand Up @@ -1320,7 +1315,7 @@ def test_invalid_example(self, fake_kedro_cli, bad_input):
)


@pytest.mark.usefixtures("chdir_to_tmp")
@pytest.mark.usefixtures("chdir_to_tmp", "patch_cookiecutter_args")
class TestToolsAndExampleFromCLI:
@pytest.mark.parametrize(
"tools",
Expand Down Expand Up @@ -1350,11 +1345,25 @@ class TestToolsAndExampleFromCLI:
],
)
@pytest.mark.parametrize("example_pipeline", ["Yes", "No"])
def test_valid_tools_flag(self, fake_kedro_cli, tools, example_pipeline, mocker):
mocker.patch(
"kedro.framework.cli.starters._make_cookiecutter_args_and_fetch_template",
side_effect=mock_make_cookiecutter_args_and_fetch_template,
def test_valid_tools_flag(self, fake_kedro_cli, tools, example_pipeline):
result = CliRunner().invoke(
fake_kedro_cli,
["new", "--tools", tools, "--example", example_pipeline],
input=_make_cli_prompt_input_without_tools(),
)

tools = _convert_tool_names_to_numbers(selected_tools=tools)
if not tools:
tools = ""

_assert_template_ok(result, tools=tools, example_pipeline=example_pipeline)
_assert_requirements_ok(result, tools=tools, repo_name="new-kedro-project")
assert "You have selected the following project tools:" in result.output
assert (
"To skip the interactive flow you can run `kedro new` with\nkedro new --name=<your-project-name> --tools=<your-project-tools> --example=<yes/no>"
in result.output
)
_clean_up_project(Path("./new-kedro-project"))

result = CliRunner().invoke(
fake_kedro_cli,
Expand Down
Loading