fre.cmor.tests.test_cmor_finder_make_simple_varlist module
tests for fre.cmor.cmor_finder.make_simple_varlist
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.empty_dir(tmp_path)
Fixture to create an empty temporary directory.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.temp_netcdf_dir(tmp_path)
Fixture to create a temporary directory with sample NetCDF files.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.temp_netcdf_dir_single_file(tmp_path)
Fixture to create a temporary directory with a single NetCDF file.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_dedup_across_datetimes(tmp_path)
Files with different datetime stamps but the same variable name should be de-duplicated so the variable appears only once. All files across all datetimes are scanned; duplicate var names are collapsed by dict assignment.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_deduplicates(tmp_path)
When multiple files share the same var_name across different datetimes, the result should contain the variable only once. Variables that only appear at a single datetime are still included.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_invalid_output_path(temp_netcdf_dir)
Test OSError when output file cannot be written.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_minority_datetime_var_included(tmp_path)
A variable that only appears at one datetime should still be returned even when most files belong to a different datetime. Scanning all files (not just those at the most-common datetime) guarantees this.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_mip_table_filter(tmp_path)
When a json_mip_table is provided, only variables present in the MIP table should appear in the result.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_mip_table_no_match(tmp_path)
When a MIP table is provided but none of the file variables are in it, the result should be an empty dict (quick_vlist stays empty → ‘no variables in target mip table found’ warning, var_list stays {}).
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_no_files(empty_dir)
Test behavior when no NetCDF files are found in directory.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_no_files_matching_pattern(tmp_path)
When glob finds no ..nc files in the directory the function should return None. Covers the ‘if not all_nc_files’ early return by patching glob.glob to return an empty list.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_no_matching_pattern(tmp_path)
Test behavior when files exist but don’t match the expected pattern.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_return_value_only(temp_netcdf_dir)
Test make_simple_varlist with output_variable_list=None returns var_list.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_single_file_hits_warning(tmp_path)
When exactly one file matches the search pattern, the function should log a warning and still return the variable. Covers the ‘elif len(files) == 1’ branch.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_single_file_warning(temp_netcdf_dir_single_file, tmp_path)
Test warning when only one file is found.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_success(temp_netcdf_dir, tmp_path)
Test successful creation of variable list from NetCDF files.