def test_add_met_config_dict_nested(metplus_config): dict_name = 'outer' beg = -3 end = 5 sub_dict_name = 'inner' sub_dict_value1 = 'value1' sub_dict_value2 = 'value2' expected_value = ( f'{dict_name} = {{beg = {beg};end = {end};{sub_dict_name} = ' f'{{var1 = {sub_dict_value1};var2 = {sub_dict_value2};}}}}') config = metplus_config() config.set('config', 'APP_OUTER_BEG', beg) config.set('config', 'APP_OUTER_END', end) config.set('config', 'APP_OUTER_INNER_VAR1', sub_dict_value1) config.set('config', 'APP_OUTER_INNER_VAR2', sub_dict_value2) cbw = CommandBuilder(config) cbw.app_name = 'app' items = { 'beg': 'int', 'end': 'int', 'inner': ('dict', None, { 'var1': ('string', 'remove_quotes', None), 'var2': ('string', 'remove_quotes', None), }), } cbw.add_met_config_dict(dict_name, items) print(f"env_var_dict: {cbw.env_var_dict}") assert cbw.env_var_dict.get('METPLUS_OUTER_DICT') == expected_value
def test_add_met_config_dict(metplus_config): dict_name = 'fcst_hr_window' beg = -3 end = 5 expected_value = f'{dict_name} = {{beg = -3;end = 5;}}' config = metplus_config() config.set('config', 'TC_GEN_FCST_HR_WINDOW_BEG', beg) config.set('config', 'TC_GEN_FCST_HR_WINDOW_END', end) cbw = CommandBuilder(config) cbw.app_name = 'tc_gen' items = { 'beg': 'int', 'end': 'int', } cbw.add_met_config_dict(dict_name, items) print(f"env_var_dict: {cbw.env_var_dict}") actual_value = cbw.env_var_dict.get('METPLUS_FCST_HR_WINDOW_DICT') assert actual_value == expected_value