diff --git a/fre/pp/frepp.py b/fre/pp/frepp.py index 4d77432d..ac48ddc2 100644 --- a/fre/pp/frepp.py +++ b/fre/pp/frepp.py @@ -252,7 +252,7 @@ def configure_xml(context, xml, platform, target, experiment, do_analysis, histo ) @click.pass_context def wrapper(context, experiment, platform, target, config_file, branch='main'): - """ - Execute fre pp checkout """ + """ - Execute fre pp steps in order """ context.forward(runFre2pp) if __name__ == "__main__": diff --git a/fre/pp/tests/test_fre_pp_cli.py b/fre/pp/tests/test_fre_pp_cli.py new file mode 100644 index 00000000..985e1799 --- /dev/null +++ b/fre/pp/tests/test_fre_pp_cli.py @@ -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 diff --git a/fre/pytest.ini b/fre/pytest.ini index 72cf74e3..20575029 100644 --- a/fre/pytest.ini +++ b/fre/pytest.ini @@ -6,7 +6,7 @@ testpaths = # fre/cmor/tests # fre/list/tests # fre/make/tests -# fre/pp/tests + fre/pp/tests # fre/run/tests # fre/test/tests # fre/yamltools/tests diff --git a/fre/tests/README.md b/fre/tests/README.md index 39f89626..31b2c2c6 100644 --- a/fre/tests/README.md +++ b/fre/tests/README.md @@ -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` diff --git a/fre/tests/test_fre_cli.py b/fre/tests/test_fre_cli.py index 40808c7b..b1b74250 100644 --- a/fre/tests/test_fre_cli.py +++ b/fre/tests/test_fre_cli.py @@ -5,6 +5,21 @@ 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 3 commandline tests: +#command, help, command does not exist + +#Test list: +#fre +#-- fre app +#-- fre catalog +#-- fre check +#-- fre cmor +#-- fre list +#-- fre make +#-- fre pp +#-- fre run def test_cli_fre(): result = runner.invoke(fre.fre) @@ -23,3 +38,110 @@ def test_cli_fre_option_dne(): #print(f'exit code of runner result is {result.exit_code}') #print(f'output of runner result is {result.output}') assert result.exit_code == 2 + +#-- fre app + +def test_cli_fre_app(): + result = runner.invoke(fre.fre, args=["app"]) + assert result.exit_code == 0 + +def test_cli_fre_app_help(): + result = runner.invoke(fre.fre, args=['--help', "app"]) + assert result.exit_code == 0 + +def test_cli_fre_app_opt_dne(): + result = runner.invoke(fre.fre, args=['optionDNE', "app"]) + assert result.exit_code == 2 + +#-- fre catalog +def test_cli_fre_catalog(): + result = runner.invoke(fre.fre, args=["catalog"]) + assert result.exit_code == 0 + +def test_cli_fre_catalog_help(): + result = runner.invoke(fre.fre, args=['--help', "catalog"]) + assert result.exit_code == 0 + +def test_cli_fre_catalog_opt_dne(): + result = runner.invoke(fre.fre, args=['optionDNE', "catalog"]) + assert result.exit_code == 2 + +#-- fre check + +def test_cli_fre_check(): + result = runner.invoke(fre.fre, args=["check"]) + assert result.exit_code == 0 + +def test_cli_fre_check_help(): + result = runner.invoke(fre.fre, args=['--help', "check"]) + assert result.exit_code == 0 + +def test_cli_fre_check_opt_dne(): + result = runner.invoke(fre.fre, args=['optionDNE', "check"]) + assert result.exit_code == 2 + +#-- fre cmor + +def test_cli_fre_cmor(): + result = runner.invoke(fre.fre, args=["cmor"]) + assert result.exit_code == 0 + +def test_cli_fre_cmor_help(): + result = runner.invoke(fre.fre, args=['--help', "cmor"]) + assert result.exit_code == 0 + +def test_cli_fre_cmor_opt_dne(): + result = runner.invoke(fre.fre, args=['optionDNE', "cmor"]) + assert result.exit_code == 2 + +#-- fre list +def test_cli_fre_list(): + result = runner.invoke(fre.fre, args=["list"]) + assert result.exit_code == 0 + +def test_cli_fre_list_help(): + result = runner.invoke(fre.fre, args=['--help', "list"]) + assert result.exit_code == 0 + +def test_cli_fre_list_opt_dne(): + result = runner.invoke(fre.fre, args=['optionDNE', "list"]) + assert result.exit_code == 2 + +#-- fre make +def test_cli_fre_make(): + result = runner.invoke(fre.fre, args=["make"]) + assert result.exit_code == 0 + +def test_cli_fre_make_help(): + result = runner.invoke(fre.fre, args=['--help', "make"]) + assert result.exit_code == 0 + +def test_cli_fre_make_opt_dne(): + result = runner.invoke(fre.fre, args=['optionDNE', "make"]) + assert result.exit_code == 2 + +#-- fre pp +def test_cli_fre_pp(): + result = runner.invoke(fre.fre, args=["pp"]) + assert result.exit_code == 0 + +def test_cli_fre_pp_help(): + result = runner.invoke(fre.fre, args=['--help', "pp"]) + assert result.exit_code == 0 + +def test_cli_fre_pp_opt_dne(): + result = runner.invoke(fre.fre, args=['optionDNE', "pp"]) + assert result.exit_code == 2 + +#-- fre run +def test_cli_fre_run(): + result = runner.invoke(fre.fre, args=["run"]) + assert result.exit_code == 0 + +def test_cli_fre_run_help(): + result = runner.invoke(fre.fre, args=['--help', "run"]) + assert result.exit_code == 0 + +def test_cli_fre_run_opt_dne(): + result = runner.invoke(fre.fre, args=['optionDNE', "run"]) + assert result.exit_code == 2