-
Notifications
You must be signed in to change notification settings - Fork 908
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
Fix --tools=all
not working properly
#3361
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
5faebf3
add fix
SajidAlamQB 0f61dd5
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto 7e7ca3f
add fix
SajidAlamQB 16ef432
Rename addons to tools (#3357)
AhdraMeraliQB 87e2e1e
Fix broken tests (#3366)
AhdraMeraliQB 9ab8759
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto f127b48
Fix variable names on _convert_tool_names_to_numbers
lrcouto 4090586
Merge branch 'bugfix/addons=all-fix' of github.com:kedro-org/kedro in…
lrcouto 47c4118
Merge branch 'bugfix/addons=all-fix' of https://github.com/kedro-org/…
SajidAlamQB 70985cc
Merge branch 'develop' into bugfix/addons=all-fix
SajidAlamQB a3eea61
Merge branch 'develop' into bugfix/addons=all-fix
SajidAlamQB fd7b734
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto 6888463
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto 143b204
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto ba0d696
Add tests for helper functions
lrcouto dab4d29
Merge branch 'develop' into bugfix/addons=all-fix
SajidAlamQB d6672a3
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto f9802c7
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto b353f63
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto 545755a
Lint
lrcouto 4bc1748
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto 93d5b50
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto c875b3c
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto 3df74ab
Return numbers to tools names on conversion from all
lrcouto a821ede
Merge branch 'bugfix/addons=all-fix' of github.com:kedro-org/kedro in…
lrcouto d33b745
Merge branch 'develop' into bugfix/addons=all-fix
lrcouto a228843
Merge branch 'develop' into bugfix/addons=all-fix
SajidAlamQB 31d7a3f
Merge branch 'develop' into bugfix/addons=all-fix
SajidAlamQB 3e6666e
Merge branch 'develop' into bugfix/addons=all-fix
SajidAlamQB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,43 +291,42 @@ def test_starter_list_with_invalid_starter_plugin( | |
assert expected in result.output | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input,expected", | ||
[ | ||
("1", ["1"]), | ||
("1,2,3", ["1", "2", "3"]), | ||
("2-4", ["2", "3", "4"]), | ||
("3-3", ["3"]), | ||
("all", ["1", "2", "3", "4", "5", "6", "7"]), | ||
("none", []), | ||
], | ||
) | ||
def test_parse_tools_valid(input, expected): | ||
result = _parse_tools_input(input) | ||
assert result == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input", | ||
["5-2", "3-1"], | ||
) | ||
def test_parse_tools_invalid_range(input, capsys): | ||
with pytest.raises(SystemExit): | ||
_parse_tools_input(input) | ||
message = f"'{input}' is an invalid range for project tools.\nPlease ensure range values go from smaller to larger." | ||
assert message in capsys.readouterr().err | ||
class TestParseToolsInput: | ||
@pytest.mark.parametrize( | ||
"input,expected", | ||
[ | ||
("1", ["1"]), | ||
("1,2,3", ["1", "2", "3"]), | ||
("2-4", ["2", "3", "4"]), | ||
("3-3", ["3"]), | ||
("all", ["1", "2", "3", "4", "5", "6", "7"]), | ||
("none", []), | ||
], | ||
) | ||
def test_parse_tools_valid(self, input, expected): | ||
result = _parse_tools_input(input) | ||
assert result == expected | ||
|
||
@pytest.mark.parametrize( | ||
"input", | ||
["5-2", "3-1"], | ||
) | ||
def test_parse_tools_invalid_range(self, input, capsys): | ||
with pytest.raises(SystemExit): | ||
_parse_tools_input(input) | ||
message = f"'{input}' is an invalid range for project tools.\nPlease ensure range values go from smaller to larger." | ||
assert message in capsys.readouterr().err | ||
|
||
@pytest.mark.parametrize( | ||
"input,last_invalid", | ||
[("0,3,5", "0"), ("1,3,8", "8"), ("0-4", "0"), ("3-9", "9")], | ||
) | ||
def test_parse_tools_invalid_selection(input, last_invalid, capsys): | ||
with pytest.raises(SystemExit): | ||
selected = _parse_tools_input(input) | ||
_validate_selection(selected) | ||
message = f"'{last_invalid}' is not a valid selection.\nPlease select from the available tools: 1, 2, 3, 4, 5, 6, 7." | ||
assert message in capsys.readouterr().err | ||
@pytest.mark.parametrize( | ||
"input,last_invalid", | ||
[("0,3,5", "0"), ("1,3,8", "8"), ("0-4", "0"), ("3-9", "9")], | ||
) | ||
def test_parse_tools_invalid_selection(self, input, last_invalid, capsys): | ||
with pytest.raises(SystemExit): | ||
selected = _parse_tools_input(input) | ||
_validate_selection(selected) | ||
message = f"'{last_invalid}' is not a valid selection.\nPlease select from the available tools: 1, 2, 3, 4, 5, 6, 7." | ||
assert message in capsys.readouterr().err | ||
|
||
|
||
@pytest.mark.usefixtures("chdir_to_tmp") | ||
|
@@ -1366,3 +1365,98 @@ def test_invalid_names(self, fake_kedro_cli, name): | |
"Kedro project names must contain only alphanumeric symbols, spaces, underscores and hyphens and be at least 2 characters long" | ||
in result.output | ||
) | ||
|
||
|
||
class TestParseYesNoToBools: | ||
@pytest.mark.parametrize( | ||
"input", | ||
["yes", "YES", "y", "Y", "yEs"], | ||
) | ||
def parse_yes_no_to_bool_responds_true(self, input): | ||
assert _parse_yes_no_to_bool(input) is True | ||
|
||
@pytest.mark.parametrize( | ||
"input", | ||
["no", "NO", "n", "N", "No", ""], | ||
) | ||
def parse_yes_no_to_bool_responds_false(self, input): | ||
assert _parse_yes_no_to_bool(input) is False | ||
|
||
def parse_yes_no_to_bool_responds_none(self): | ||
assert _parse_yes_no_to_bool(None) is None | ||
|
||
|
||
class TestValidateSelection: | ||
def test_validate_selection_valid(self): | ||
tools = ["1", "2", "3", "4"] | ||
assert _validate_selection(tools) is None | ||
|
||
def test_validate_selection_invalid_single_tool(self, capsys): | ||
tools = ["8"] | ||
with pytest.raises(SystemExit): | ||
_validate_selection(tools) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add an assert for the correct error message? E.g the implementation for |
||
message = "is not a valid selection.\nPlease select from the available tools: 1, 2, 3, 4, 5, 6, 7." | ||
assert message in capsys.readouterr().err | ||
|
||
def test_validate_selection_invalid_multiple_tools(self, capsys): | ||
tools = ["8", "10", "15"] | ||
with pytest.raises(SystemExit): | ||
_validate_selection(tools) | ||
message = "is not a valid selection.\nPlease select from the available tools: 1, 2, 3, 4, 5, 6, 7." | ||
assert message in capsys.readouterr().err | ||
|
||
def test_validate_selection_mix_valid_invalid_tools(self, capsys): | ||
tools = ["1", "8", "3", "15"] | ||
with pytest.raises(SystemExit): | ||
_validate_selection(tools) | ||
message = "is not a valid selection.\nPlease select from the available tools: 1, 2, 3, 4, 5, 6, 7." | ||
assert message in capsys.readouterr().err | ||
|
||
def test_validate_selection_empty_list(self): | ||
tools = [] | ||
assert _validate_selection(tools) is None | ||
|
||
|
||
class TestConvertToolNamesToNumbers: | ||
def test_convert_tool_names_to_numbers_with_valid_tools(self): | ||
selected_tools = "lint,test,docs" | ||
result = _convert_tool_names_to_numbers(selected_tools) | ||
assert result == "1,2,4" | ||
|
||
def test_convert_tool_names_to_numbers_with_none(self): | ||
result = _convert_tool_names_to_numbers(None) | ||
assert result is None | ||
|
||
def test_convert_tool_names_to_numbers_with_empty_string(self): | ||
selected_tools = "" | ||
result = _convert_tool_names_to_numbers(selected_tools) | ||
assert result == "" | ||
|
||
def test_convert_tool_names_to_numbers_with_none_string(self): | ||
selected_tools = "none" | ||
result = _convert_tool_names_to_numbers(selected_tools) | ||
assert result == "" | ||
|
||
def test_convert_tool_names_to_numbers_with_all_string(self): | ||
result = _convert_tool_names_to_numbers("all") | ||
assert result == "1,2,3,4,5,6,7" | ||
|
||
def test_convert_tool_names_to_numbers_with_mixed_valid_invalid_tools(self): | ||
selected_tools = "lint,invalid_tool,docs" | ||
result = _convert_tool_names_to_numbers(selected_tools) | ||
assert result == "1,4" | ||
|
||
def test_convert_tool_names_to_numbers_with_whitespace(self): | ||
selected_tools = " lint , test , docs " | ||
result = _convert_tool_names_to_numbers(selected_tools) | ||
assert result == "1,2,4" | ||
|
||
def test_convert_tool_names_to_numbers_with_case_insensitive_tools(self): | ||
selected_tools = "Lint,TEST,Docs" | ||
result = _convert_tool_names_to_numbers(selected_tools) | ||
assert result == "1,2,4" | ||
|
||
def test_convert_tool_names_to_numbers_with_invalid_tools(self): | ||
selected_tools = "invalid_tool1,invalid_tool2" | ||
result = _convert_tool_names_to_numbers(selected_tools) | ||
assert result == "" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move the tests for
parse_tools_input
into their own class as well? For consistency