fremor.tests.test_cli module
CLI Tests for fremor subcommands
Tests the command-line-interface calls for the fremor CLI (fremor package). Each tool generally gets 3 tests:
fremor $tool, checking for exit code 0 or 2 (fails if cli isn’t configured right)
fremor $tool –help, checking for exit code 0 (fails if the code doesn’t run)
fremor $tool –optionDNE, checking for exit code 2 (fails if cli isn’t configured right and thinks the tool has a –optionDNE option)
We also have a set of more complicated tests for testing the full set of command-line args for fremor yaml and fremor run.
Migrated from NOAA-GFDL/fre-cli fre/tests/test_fre_cmor_cli.py.
- fremor.tests.test_cli.test_cli_fremor()
fremor
- fremor.tests.test_cli.test_cli_fremor_config()
fremor config (no args)
- fremor.tests.test_cli.test_cli_fremor_config_case1(cli_sos_nc_file)
fremor config – generate a CMOR YAML config from a mock pp directory tree. Uses the ocean_sos_var_file test data with a mock pp layout.
- fremor.tests.test_cli.test_cli_fremor_config_help()
fremor config –help
- fremor.tests.test_cli.test_cli_fremor_config_opt_dne()
fremor config optionDNE
- fremor.tests.test_cli.test_cli_fremor_find()
fremor find (no args)
- fremor.tests.test_cli.test_cli_fremor_find_cmip6_case1()
fremor find, test-use case searching for variables in cmip6 tables
- fremor.tests.test_cli.test_cli_fremor_find_cmip6_case2()
fremor find, test-use case searching for variables in cmip6 tables
- fremor.tests.test_cli.test_cli_fremor_find_help()
fremor find –help
- fremor.tests.test_cli.test_cli_fremor_find_opt_dne()
fremor find optionDNE
- fremor.tests.test_cli.test_cli_fremor_help()
fremor –help
- fremor.tests.test_cli.test_cli_fremor_help_and_debuglog(tmp_path)
fremor -vv -l LOG yaml –help (logs created by group callback)
- fremor.tests.test_cli.test_cli_fremor_help_and_infolog(tmp_path)
fremor -v -l LOG yaml –help
- fremor.tests.test_cli.test_cli_fremor_help_and_quietlog(tmp_path)
fremor -q -l LOG yaml –help
- fremor.tests.test_cli.test_cli_fremor_init()
fremor init (no args)
- fremor.tests.test_cli.test_cli_fremor_init_cmip6_exp_config(tmp_path)
fremor init – generate a CMIP6 experiment config template.
- fremor.tests.test_cli.test_cli_fremor_init_cmip7_exp_config(tmp_path)
fremor init – generate a CMIP7 experiment config template.
- fremor.tests.test_cli.test_cli_fremor_init_default_name(tmp_path)
fremor init – when no –exp_config is given and no –tables_dir, a default-named file should be created in the current directory.
- fremor.tests.test_cli.test_cli_fremor_init_help()
fremor init –help
- fremor.tests.test_cli.test_cli_fremor_init_opt_dne()
fremor init optionDNE
- fremor.tests.test_cli.test_cli_fremor_opt_dne()
fremor optionDNE
- fremor.tests.test_cli.test_cli_fremor_resolve()
fremor resolve
- fremor.tests.test_cli.test_cli_fremor_resolve_case1(tmp_path)
fremor resolve –output should write the resolved AM5 YAML
- fremor.tests.test_cli.test_cli_fremor_resolve_case2_stdout()
fremor resolve without –output should print resolved YAML to stdout
- fremor.tests.test_cli.test_cli_fremor_resolve_help()
fremor resolve –help
- fremor.tests.test_cli.test_cli_fremor_resolve_opt_dne()
fremor resolve optionDNE
- fremor.tests.test_cli.test_cli_fremor_run()
fremor run (no args)
- fremor.tests.test_cli.test_cli_fremor_run_case1(cli_sos_nc_file, tmp_path)
fremor run, test-use case: sos → sos (CMIP6)
- fremor.tests.test_cli.test_cli_fremor_run_case2(cli_sosv2_nc_file, tmp_path)
fremor run, test error case: filename variable != file variable (CMIP6). The sosV2 file has variable ‘sos’ inside, but the varlist expects ‘sosV2’ as the modeler variable name. This mismatch should cause a non-zero exit code.
- fremor.tests.test_cli.test_cli_fremor_run_case3(cli_mapped_nc_file, tmp_path)
fremor run, test-use case 3: sea_sfc_salinity → sos mapped variable (CMIP6)
- fremor.tests.test_cli.test_cli_fremor_run_cmip7_case1(cli_sos_nc_file, tmp_path)
fremor run, test-use case for cmip7: sos → sos
- fremor.tests.test_cli.test_cli_fremor_run_cmip7_case2(cli_sosv2_nc_file, tmp_path)
fremor run, test error case for cmip7: filename variable != file variable. The sosV2 file has variable ‘sos’ inside, but the varlist expects ‘sosV2’ as the modeler variable name. This mismatch should cause a non-zero exit code.
- fremor.tests.test_cli.test_cli_fremor_run_cmip7_case3(cli_mapped_nc_file, tmp_path)
fremor run, test-use case 3 for cmip7: sea_sfc_salinity → sos mapped variable
- fremor.tests.test_cli.test_cli_fremor_run_help()
fremor run –help
- fremor.tests.test_cli.test_cli_fremor_run_opt_dne()
fremor run optionDNE
- fremor.tests.test_cli.test_cli_fremor_run_with_logfile(cli_sos_nc_file, tmp_path)
fremor -vv -l LOGFILE run …
Runs a real CMOR workflow with the -l flag and verifies that the resulting log file contains log lines from both cli.py (the CLI entry point) and cmor_mixer (the CMOR processing module).
- fremor.tests.test_cli.test_cli_fremor_run_with_logfile_omission_case(cli_sos_nc_file, cli_sosv2_nc_file, tmp_path)
fremor -vv -l LOGFILE run …
Uses a varlist where sos->sos succeeds and sosV2->tob fails (tob is a valid CMIP6_Omon variable but the sosV2 file contains sos data, not tob). Verifies the OMISSION LOG appears in the log file with the failed variable info.
- fremor.tests.test_cli.test_cli_fremor_varlist()
fremor varlist (no args)
- fremor.tests.test_cli.test_cli_fremor_varlist_cmip6_table_filter(cli_sos_nc_file, cli_sosv2_nc_file, cli_mapped_nc_file, tmp_path)
fremor varlist — with CMIP6 Omon MIP table filter. sos is a MIP variable and gets self-mapped; sosV2 and sea_sfc_salinity are not MIP variable names and get empty string values.
- fremor.tests.test_cli.test_cli_fremor_varlist_cmip7_table_filter(cli_sos_nc_file, cli_sosv2_nc_file, cli_mapped_nc_file, tmp_path)
fremor varlist — with CMIP7 ocean MIP table filter. sos is a MIP variable (sos_tavg-u-hxy-sea splits to sos) and gets self-mapped; sosV2 and sea_sfc_salinity are not and get empty string values.
- fremor.tests.test_cli.test_cli_fremor_varlist_help()
fremor varlist –help
- fremor.tests.test_cli.test_cli_fremor_varlist_no_table_filter(cli_sos_nc_file, cli_sosv2_nc_file, cli_mapped_nc_file, tmp_path)
fremor varlist — no MIP table filter. Creates a variable list from the ocean_sos_var_file test data without a MIP table, so sos, sosV2, and sea_sfc_salinity should all appear.
- fremor.tests.test_cli.test_cli_fremor_varlist_opt_dne()
fremor varlist optionDNE
- fremor.tests.test_cli.test_cli_fremor_yaml()
fremor yaml
- fremor.tests.test_cli.test_cli_fremor_yaml_case1(mock_subtool, tmp_path)
fremor yaml –dry_run -y YAMLFILE
- fremor.tests.test_cli.test_cli_fremor_yaml_help()
fremor yaml –help
- fremor.tests.test_cli.test_cli_fremor_yaml_opt_dne()
fremor yaml optionDNE
- fremor.tests.test_cli.test_setup_test_files(cli_sos_nc_file, cli_sosv2_nc_file, cli_mapped_nc_file)
Verify all required NetCDF test files exist via session-scoped fixtures.