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. Covers the ‘var_name already in target varlist, skip’ branch.
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_deduplicates(tmp_path)
When multiple files share the same var_name, the result should contain the variable only once (duplicate skip path).
- fre.cmor.tests.test_cmor_finder_make_simple_varlist.test_make_simple_varlist_index_error_on_datetime(tmp_path)
When os.path.basename(one_file).split(‘.’)[-3] raises IndexError (e.g. a file with fewer than 3 dot-segments sneaks in), the function should catch it, set one_datetime = None, and fall back to the ‘*nc’ search pattern. Covers the except IndexError branch and the one_datetime is None path.
- 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_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 the initial probe finds a file but the subsequent glob with the derived search_pattern returns no files, the function should return None. Covers the ‘if not files’ early return.
- 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.