-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from NOAA-GFDL/122.cli.separate
122.cli.separate
- Loading branch information
Showing
5 changed files
with
236 additions
and
2 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
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,95 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from fre import fre | ||
from fre import pp | ||
|
||
from click.testing import CliRunner | ||
runner = CliRunner() | ||
|
||
#tests are structured in the manner of: | ||
#https://click.palletsprojects.com/en/8.1.x/testing/ | ||
#general intent for these tests is that each fre tool has 2 commandline tests: | ||
#help, command does not exist | ||
|
||
#Test list: | ||
#fre pp (covered in fre/tests, not fre/pp/tests) | ||
#-- fre pp checkout | ||
#-- fre pp configure-xml | ||
#-- fre pp configure-yaml | ||
#-- fre pp install | ||
#-- fre pp run | ||
#-- fre pp status | ||
#-- fre pp validate | ||
#-- fre pp wrapper | ||
|
||
#-- fre pp checkout | ||
def test_cli_fre_pp_checkout_help(): | ||
result = runner.invoke(fre.fre, args=['--help', "pp checkout"]) | ||
assert result.exit_code == 0 | ||
|
||
def test_cli_fre_pp_checkout_opt_dne(): | ||
result = runner.invoke(fre.fre, args=['optionDNE', "pp checkout"]) | ||
assert result.exit_code == 2 | ||
|
||
#-- fre pp configure-xml | ||
def test_cli_fre_pp_configure_xml_help(): | ||
result = runner.invoke(fre.fre, args=['--help', "pp configure-xml"]) | ||
assert result.exit_code == 0 | ||
|
||
def test_cli_fre_pp_configure_xml_opt_dne(): | ||
result = runner.invoke(fre.fre, args=['optionDNE', "pp configure-xml"]) | ||
assert result.exit_code == 2 | ||
|
||
#-- fre pp configure-yaml | ||
def test_cli_fre_pp_configure_yaml_help(): | ||
result = runner.invoke(fre.fre, args=['--help', "pp configure-yaml"]) | ||
assert result.exit_code == 0 | ||
|
||
def test_cli_fre_pp_configure_yaml_opt_dne(): | ||
result = runner.invoke(fre.fre, args=['optionDNE', "pp configure-yaml"]) | ||
assert result.exit_code == 2 | ||
|
||
#-- fre pp install | ||
def test_cli_fre_pp_install_help(): | ||
result = runner.invoke(fre.fre, args=['--help', "pp install"]) | ||
assert result.exit_code == 0 | ||
|
||
def test_cli_fre_pp_install_opt_dne(): | ||
result = runner.invoke(fre.fre, args=['optionDNE', "pp install"]) | ||
assert result.exit_code == 2 | ||
|
||
#-- fre pp run | ||
def test_cli_fre_pp_run_help(): | ||
result = runner.invoke(fre.fre, args=['--help', "pp run"]) | ||
assert result.exit_code == 0 | ||
|
||
def test_cli_fre_pp_run_opt_dne(): | ||
result = runner.invoke(fre.fre, args=['optionDNE', "pp run"]) | ||
assert result.exit_code == 2 | ||
|
||
#-- fre pp status | ||
def test_cli_fre_pp_status_help(): | ||
result = runner.invoke(fre.fre, args=['--help', "pp status"]) | ||
assert result.exit_code == 0 | ||
|
||
def test_cli_fre_pp_status_opt_dne(): | ||
result = runner.invoke(fre.fre, args=['optionDNE', "pp status"]) | ||
assert result.exit_code == 2 | ||
|
||
#-- fre pp validate | ||
def test_cli_fre_pp_validate_help(): | ||
result = runner.invoke(fre.fre, args=['--help', "pp validate"]) | ||
assert result.exit_code == 0 | ||
|
||
def test_cli_fre_pp_validate_opt_dne(): | ||
result = runner.invoke(fre.fre, args=['optionDNE', "pp validate"]) | ||
assert result.exit_code == 2 | ||
|
||
#-- fre pp wrapper | ||
def test_cli_fre_pp_wrapper_help(): | ||
result = runner.invoke(fre.fre, args=['--help', "pp wrapper"]) | ||
assert result.exit_code == 0 | ||
|
||
def test_cli_fre_pp_wrapper_opt_dne(): | ||
result = runner.invoke(fre.fre, args=['optionDNE', "pp wrapper"]) | ||
assert result.exit_code == 2 |
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 |
---|---|---|
@@ -1,3 +1,20 @@ | ||
note- this directory is for unit tests assessing `fre` functionality, and NOT for code corresponding to the command `fre test` | ||
|
||
to run the tests as intended, simply call `pytest` from the root directory of this repository. | ||
|
||
From the root directory of this repository, if you want to... | ||
|
||
Invoke all tests (intended use): | ||
`pytest fre/tests/` | ||
|
||
Invoke all tests in a single file: | ||
`pytest fre/tests/test_fre_cli.py` | ||
|
||
Invoke a single test in a file: | ||
`pytest fre/tests/test_fre_cli.py::test_cli_fre_option_dne` | ||
|
||
|
||
Note that pytest will not print stdout from individual tests. If you want to... | ||
|
||
Print stdout from an invoked test (debugging with print statements): | ||
`pytest fre/tests/test_fre_cli.py::test_cli_fre_option_dne -s` |
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