fre.cmor.tests.test_cmor_helpers module

tests for fre.cmor helper functions in cmor_helpers

fre.cmor.tests.test_cmor_helpers.test_create_lev_bnds_length_mismatch()

create_lev_bnds should raise ValueError when len(with_these) != len(bound_these)+1

fre.cmor.tests.test_cmor_helpers.test_create_lev_bnds_length_mismatch_too_long()

same check, but with_these is too long instead of too short

fre.cmor.tests.test_cmor_helpers.test_create_tmp_dir_oserror(tmp_path)

create_tmp_dir should raise OSError when directory creation fails

fre.cmor.tests.test_cmor_helpers.test_create_tmp_dir_success(tmp_path)

create_tmp_dir should create a tmp/ subdirectory and return its path

fre.cmor.tests.test_cmor_helpers.test_create_tmp_dir_with_exp_config(tmp_path)

when json_exp_config has an outpath key, a subdirectory should also be created

fre.cmor.tests.test_cmor_helpers.test_filter_brands_all_eliminated()

should raise ValueError when all brands are filtered out

fre.cmor.tests.test_cmor_helpers.test_filter_brands_multiple_remain()

should raise ValueError when multiple brands survive filtering

fre.cmor.tests.test_cmor_helpers.test_filter_brands_time_filter_selects_inst()

brand with time1 (instantaneous) should be selected when input lacks time_bnds

fre.cmor.tests.test_cmor_helpers.test_filter_brands_time_filter_selects_mean()

brand with time (mean) should be selected when input has time_bnds

fre.cmor.tests.test_cmor_helpers.test_filter_brands_vertical_filter()

vertical filter should select the brand whose MIP dims contain the expected vert dim

fre.cmor.tests.test_cmor_helpers.test_find_gold_ocean_statics_file_archive_missing(tmp_path)

when the archive gold file does not exist on disk (i.e. not at PPAN), the function should create the local directory tree but return None because there’s nothing to copy.

fre.cmor.tests.test_cmor_helpers.test_find_gold_ocean_statics_file_mock_copy(tmp_path)

exercise the full copy path by creating a fake archive gold file in tmp_path and monkeypatching ARCHIVE_GOLD_DATA_DIR so the function finds it.

fre.cmor.tests.test_cmor_helpers.test_find_gold_ocean_statics_file_none_arg()

put_copy_here=None should return None immediately

fre.cmor.tests.test_cmor_helpers.test_find_statics_file_nothing_found()

what happens when a statics file is found given a bronx directory structure

fre.cmor.tests.test_cmor_helpers.test_find_statics_file_success()

what happens when no statics file is found given a bronx directory structure

fre.cmor.tests.test_cmor_helpers.test_get_bronx_freq_from_mip_table_invalid_freq(tmp_path)

should raise KeyError when the table frequency is not a valid MIP frequency

fre.cmor.tests.test_cmor_helpers.test_get_bronx_freq_from_mip_table_no_freq(tmp_path)

should raise bronx-equivalent frequency for a valid table

fre.cmor.tests.test_cmor_helpers.test_get_bronx_freq_from_mip_table_success(tmp_path)

should return the bronx-equivalent frequency for a valid table

fre.cmor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_no_filter()

all 5 date ranges should appear when start/stop are None

fre.cmor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_no_matches_raises()

if the filter excludes everything, ValueError should be raised

fre.cmor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_none_arr_raises()

passing iso_daterange_arr=None should raise ValueError

fre.cmor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_with_start()

only date ranges whose start-year >= 2000 should survive

fre.cmor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_with_start_and_stop()

start=1995 stop=2004 should give exactly two ranges

fre.cmor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_with_stop()

only date ranges whose end-year <= 2004 should survive

fre.cmor.tests.test_cmor_helpers.test_get_json_file_data_invalid_json(tmp_path)

should raise FileNotFoundError (wrapping JSONDecodeError) for invalid JSON

fre.cmor.tests.test_cmor_helpers.test_get_json_file_data_nonexistent()

should raise FileNotFoundError for a missing file

fre.cmor.tests.test_cmor_helpers.test_get_json_file_data_success(tmp_path)

should load and return JSON content

fre.cmor.tests.test_cmor_helpers.test_iso_to_bronx_chunk()

tests value error raising by iso_to_bronx_chunk

fre.cmor.tests.test_cmor_helpers.test_print_data_minmax_no_exception_case1()

checks to make sure this doesn’t raise an exception

fre.cmor.tests.test_cmor_helpers.test_print_data_minmax_no_exception_case2()

checks to make sure this doesn’t raise an exception

fre.cmor.tests.test_cmor_helpers.test_print_data_minmax_no_exception_case3()

checks to make sure this doesn’t raise an exception

fre.cmor.tests.test_cmor_helpers.test_update_grid_and_label_none_grid(tmp_path)

should raise ValueError when new_grid is None

fre.cmor.tests.test_cmor_helpers.test_update_grid_and_label_none_grid_label(tmp_path)

should raise ValueError when new_grid_label is None

fre.cmor.tests.test_cmor_helpers.test_update_grid_and_label_none_nom_res(tmp_path)

should raise ValueError when new_nom_res is None