fremor.tests.test_cmor_helpers module

tests for fremor helper functions in cmor_helpers

fremor.tests.test_cmor_helpers.test_create_lev_bnds_length_mismatch()

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

fremor.tests.test_cmor_helpers.test_create_lev_bnds_length_mismatch_too_long()

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

fremor.tests.test_cmor_helpers.test_create_tmp_dir_oserror()

create_tmp_dir should raise OSError when directory creation fails

fremor.tests.test_cmor_helpers.test_create_tmp_dir_success(tmp_path)

create_tmp_dir should create a tmp/ subdirectory and return its path

fremor.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

fremor.tests.test_cmor_helpers.test_filter_brands_all_eliminated()

should raise ValueError when all brands are filtered out

fremor.tests.test_cmor_helpers.test_filter_brands_multiple_remain()

should raise ValueError when multiple brands survive filtering

fremor.tests.test_cmor_helpers.test_filter_brands_time_filter_selects_inst()

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

fremor.tests.test_cmor_helpers.test_filter_brands_time_filter_selects_mean()

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

fremor.tests.test_cmor_helpers.test_filter_brands_vertical_filter()

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

fremor.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.

fremor.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.

fremor.tests.test_cmor_helpers.test_find_gold_ocean_statics_file_none_arg()

put_copy_here=None should return None immediately

fremor.tests.test_cmor_helpers.test_find_statics_file_nothing_found()

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

fremor.tests.test_cmor_helpers.test_find_statics_file_success(tmp_path)

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

fremor.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

fremor.tests.test_cmor_helpers.test_get_bronx_freq_from_mip_table_no_freq(tmp_path)

should raise bronx-equivalent frequency for a valid table

fremor.tests.test_cmor_helpers.test_get_bronx_freq_from_mip_table_success(tmp_path)

should return the bronx-equivalent frequency for a valid table

fremor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_no_filter()

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

fremor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_no_matches_raises()

if the filter excludes everything, ValueError should be raised

fremor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_none_arr_raises()

passing iso_daterange_arr=None should raise ValueError

fremor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_with_start()

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

fremor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_with_start_and_stop()

start=1995 stop=2004 should give exactly two ranges

fremor.tests.test_cmor_helpers.test_get_iso_datetime_ranges_with_stop()

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

fremor.tests.test_cmor_helpers.test_get_json_file_data_invalid_json(tmp_path)

should raise FileNotFoundError (wrapping JSONDecodeError) for invalid JSON

fremor.tests.test_cmor_helpers.test_get_json_file_data_nonexistent()

should raise FileNotFoundError for a missing file

fremor.tests.test_cmor_helpers.test_get_json_file_data_success(tmp_path)

should load and return JSON content

fremor.tests.test_cmor_helpers.test_iso_to_bronx_chunk()

tests value error raising by iso_to_bronx_chunk

fremor.tests.test_cmor_helpers.test_print_data_minmax_no_exception_case1()

checks to make sure this doesn’t raise an exception

fremor.tests.test_cmor_helpers.test_print_data_minmax_no_exception_case2()

checks to make sure this doesn’t raise an exception

fremor.tests.test_cmor_helpers.test_print_data_minmax_no_exception_case3()

checks to make sure this doesn’t raise an exception

fremor.tests.test_cmor_helpers.test_update_grid_and_label_none_grid(tmp_path)

should raise ValueError when new_grid is None

fremor.tests.test_cmor_helpers.test_update_grid_and_label_none_grid_label(tmp_path)

should raise ValueError when new_grid_label is None

fremor.tests.test_cmor_helpers.test_update_grid_and_label_none_nom_res(tmp_path)

should raise ValueError when new_nom_res is None