Exemple #1
0
def test_add_met_config_list(metplus_config, mp_config_name, met_config_name,
                             c_dict_key, remove_quotes, expected_output):
    cbw = CommandBuilder(metplus_config())

    # set some config variables to test
    cbw.config.set('config', 'TEST_LIST_1', 'value_1,   value2')
    cbw.config.set('config', 'TEST_LIST_3', "'value_1',   'value2'")
    cbw.config.set('config', 'TEST_LIST_4', '"value_1",   "value2"')

    extra_args = {}
    if remove_quotes:
        extra_args['remove_quotes'] = True

    key = c_dict_key
    if key is None:
        key = met_config_name

    key = key.upper()

    cbw.add_met_config(name=met_config_name,
                       data_type='list',
                       env_var_name=key,
                       metplus_configs=[mp_config_name],
                       extra_args=extra_args)
    print(f"KEY: {key}, ENV VARS: {cbw.env_var_dict}")
    assert cbw.env_var_dict.get(f'METPLUS_{key}', '') == expected_output
Exemple #2
0
def test_add_met_config_bool(metplus_config, mp_config_name, met_config_name,
                             c_dict_key, uppercase, expected_output, is_ok):
    cbw = CommandBuilder(metplus_config())

    # set some config variables to test
    cbw.config.set('config', 'TEST_BOOL_1', True)
    cbw.config.set('config', 'TEST_BOOL_3', False)
    cbw.config.set('config', 'TEST_BOOL_4', 'chicken')

    extra_args = {}
    if not uppercase:
        extra_args['uppercase'] = False

    key = c_dict_key
    if key is None:
        key = met_config_name
    key = key.upper()

    cbw.add_met_config(name=met_config_name,
                       data_type='bool',
                       env_var_name=key,
                       metplus_configs=[mp_config_name],
                       extra_args=extra_args)

    assert cbw.env_var_dict.get(f'METPLUS_{key}', '') == expected_output
    assert cbw.isOK == is_ok
Exemple #3
0
def test_add_met_config(metplus_config):
    config = metplus_config()
    value = 5
    config.set('config', 'TC_GEN_VALID_FREQUENCY', value)
    cbw = CommandBuilder(config)
    cbw.add_met_config(name='valid_freq',
                       data_type='int',
                       metplus_configs=[
                           'TC_GEN_VALID_FREQUENCY',
                           'TC_GEN_VALID_FREQ',
                       ])
    print(f"env_var_dict: {cbw.env_var_dict}")
    expected_value = f'valid_freq = {value};'
    assert cbw.env_var_dict['METPLUS_VALID_FREQ'] == expected_value
Exemple #4
0
def test_add_met_config_list_allow_empty(metplus_config, mp_config_name,
                                         allow_empty, expected_output):
    cbw = CommandBuilder(metplus_config())

    # set some config variables to test
    cbw.config.set('config', 'TEST_LIST_1', '')

    extra_args = {}
    if allow_empty:
        extra_args['allow_empty'] = True

    met_config_name = mp_config_name.lower()

    cbw.add_met_config(name=met_config_name,
                       data_type='list',
                       metplus_configs=[mp_config_name],
                       extra_args=extra_args)

    assert cbw.env_var_dict.get(f'METPLUS_{mp_config_name}',
                                '') == expected_output
Exemple #5
0
def test_add_met_config_float(metplus_config, mp_config_name, met_config_name,
                              c_dict_key, expected_output, is_ok):
    cbw = CommandBuilder(metplus_config())

    # set some config variables to test
    cbw.config.set('config', 'TEST_FLOAT_1', 7.0)
    cbw.config.set('config', 'TEST_FLOAT_3', 4)
    cbw.config.set('config', 'TEST_FLOAT_4', 'chicken')

    key = c_dict_key
    if key is None:
        key = met_config_name
    key = key.upper()

    cbw.add_met_config(name=met_config_name,
                       data_type='float',
                       env_var_name=key,
                       metplus_configs=[mp_config_name])

    assert cbw.env_var_dict.get(f'METPLUS_{key}', '') == expected_output
    assert cbw.isOK == is_ok
Exemple #6
0
def test_add_met_config_string(metplus_config, mp_config_name, met_config_name,
                               c_dict_key, remove_quotes, expected_output):
    cbw = CommandBuilder(metplus_config())

    # set some config variables to test
    cbw.config.set('config', 'TEST_STRING_1', 'value_1')

    extra_args = {}
    if remove_quotes:
        extra_args['remove_quotes'] = True

    key = c_dict_key
    if key is None:
        key = met_config_name
    key = key.upper()

    cbw.add_met_config(name=met_config_name,
                       data_type='string',
                       env_var_name=key,
                       metplus_configs=[mp_config_name],
                       extra_args=extra_args)

    assert cbw.env_var_dict.get(f'METPLUS_{key}', '') == expected_output
Exemple #7
0
def test_add_met_config_thresh(metplus_config, mp_config_name, met_config_name,
                               c_dict_key, expected_output, is_ok):
    cbw = CommandBuilder(metplus_config())

    # set some config variables to test
    cbw.config.set('config', 'TEST_THRESH_1', 'gt74')
    cbw.config.set('config', 'TEST_THRESH_3', '>=74.4')
    cbw.config.set('config', 'TEST_THRESH_4', 'chicken')
    cbw.config.set('config', 'TEST_THRESH_5', '>CDP40&&<=CDP50')
    cbw.config.set('config', 'TEST_THRESH_6', 'NA')

    key = c_dict_key
    if key is None:
        key = met_config_name
    key = key.upper()

    cbw.add_met_config(name=met_config_name,
                       env_var_name=key,
                       data_type='thresh',
                       metplus_configs=[mp_config_name])

    print(f"KEY: {key}, ENV VARS: {cbw.env_var_dict}")
    assert cbw.env_var_dict.get(f'METPLUS_{key}', '') == expected_output
    assert cbw.isOK == is_ok