-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various fixes and improvements to the glotaran command line interface. * Changed CLI save plugin to folder * Added outputformat option to CLI * Added basic test for CLI * Rename CLI entrypoint to main and add more CLI tests * 👌 CLI use same default for non_negative_least_squares as scheme * 👌 CLI dedent pluginlist output * 🩹 CLI fixed result outformat accepting none supported formats Co-authored-by: Joris Snellenburg <[email protected]> Co-authored-by: s-weigand <[email protected]>
- Loading branch information
1 parent
5d24823
commit b89196e
Showing
9 changed files
with
138 additions
and
39 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from glotaran.cli.main import main |
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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from glotaran.cli.commands.util import project_io_list_supporting_plugins | ||
|
||
|
||
def test_project_io_list_supporting_plugins_save_result(): | ||
"""Same as used in ``--outformat`` CLI option.""" | ||
result = project_io_list_supporting_plugins("save_result", ("yml_str")) | ||
|
||
assert "csv" not in result | ||
assert "yml_str" not in result | ||
assert "folder" in result |
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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from pathlib import Path | ||
|
||
from click.testing import CliRunner | ||
|
||
from glotaran.cli import main | ||
|
||
|
||
def test_cli_help(): | ||
"""Test the CLI help options.""" | ||
runner = CliRunner() | ||
result = runner.invoke(main) | ||
assert result.exit_code == 0 | ||
help_result = runner.invoke(main, ["--help"], prog_name="glotaran") | ||
assert help_result.exit_code == 0 | ||
assert "Usage: glotaran [OPTIONS] COMMAND [ARGS]..." in help_result.output | ||
|
||
|
||
def test_cli_pluginlist(): | ||
"""Test the CLI pluginlist option.""" | ||
runner = CliRunner() | ||
result = runner.invoke(main, ["pluginlist"], prog_name="glotaran") | ||
assert result.exit_code == 0 | ||
assert "Installed Glotaran Plugins" in result.output | ||
|
||
|
||
def test_cli_validate_parameters_file(tmp_path: Path): | ||
"""Test the CLI pluginlist option.""" | ||
empty_file = tmp_path.joinpath("empty_file.yml") | ||
empty_file.touch() | ||
runner = CliRunner() | ||
result_ok = runner.invoke( | ||
main, ["validate", "--parameters_file", str(empty_file)], prog_name="glotaran" | ||
) | ||
assert result_ok.exit_code == 0 | ||
assert "Type 'glotaran validate --help' for more info." in result_ok.output | ||
non_existing_file = tmp_path.joinpath("_does_not_exist_.yml") | ||
result_file_not_exist = runner.invoke( | ||
main, ["validate", "--parameters_file", str(non_existing_file)], prog_name="glotaran" | ||
) | ||
assert result_file_not_exist.exit_code == 2 | ||
assert all( | ||
substring in result_file_not_exist.output for substring in ("Error", "does not exist") | ||
) |
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