Example #1
0
def test_list_merging():
    """
    Load two configs and check we properly either override or append
    """
    cfg = Config(TEST_LIST1)
    assert len(cfg.configuration['Filters']) == 1
    assert cfg.configuration['ValidGroups'][0] == 'bullshitgroup'
    cfg.load_config(TEST_LIST2)
    assert len(cfg.configuration['Filters']) == 2
    assert len(cfg.configuration['ValidGroups']) == 1
    assert cfg.configuration['ValidGroups'][0] == 'System/Libraries'
Example #2
0
def test_list_merging():
    """
    Load two configs and check we loaded up in proper older with
    replacing based on TOML syntax
    """
    cfg = Config(TEST_LIST1)
    assert len(cfg.configuration['Filters']) == 1
    assert cfg.configuration['ValidGroups'][0] == 'bullshitgroup'
    cfg.load_config(TEST_LIST2)
    assert len(cfg.conf_files) == 3
    assert len(cfg.configuration['Filters']) == 1
    assert len(cfg.configuration['ValidGroups']) == 1
    assert cfg.configuration['ValidGroups'][0] == 'System/Libraries'
Example #3
0
def test_double_config():
    """
    Load two configs and make sure we properly load all the values
    """
    cfg = Config(TEST_CONFIG)
    assert len(cfg.conf_files) == 2
    assert cfg.configuration['ExtraMenuNeeds'][0] == 'gnome'
    # shovel in another config
    cfg.load_config(TEST_CONFIG_2)
    assert len(cfg.conf_files) == 3
    assert cfg.configuration['ExtraMenuNeeds'][-1] == 'windows'
    assert cfg.configuration['WarnOnFunction']['crypto-policy-non-compliance-openssl']['f_name'] == 'REPLACED'
    assert cfg.configuration['WarnOnFunction']['crypto-policy-3']['f_name'] == 'new_blobie'
Example #4
0
def test_double_config():
    """
    Load two configs and make sure we overshadow, not replace
    """
    cfg = Config(TEST_CONFIG)
    assert len(cfg.conf_files) == 1
    assert cfg.configuration['ExtraMenuNeeds'][0] == 'gnome'
    # shovel in another config
    cfg.load_config(TEST_CONFIG_2)
    assert len(cfg.conf_files) == 2
    assert cfg.configuration['Distribution'] == 'Fedora Project'
    assert cfg.configuration['Vendor'] == 'SUSE'
    assert cfg.configuration['ExtraMenuNeeds'][0] == 'windows'
    assert cfg.configuration['WarnOnFunction'][
        'crypto-policy-non-compliance-gnutls-1']
    assert cfg.configuration['WarnOnFunction'][
        'crypto-policy-non-compliance-openssl']['f_name'] == 'REPLACED'
    assert cfg.configuration['WarnOnFunction']['crypto-policy-3'][
        'f_name'] == 'new_blobie'
Example #5
0
        sys.exit(0)
    elif o[0] in ('-v', '--verbose'):
        verbose = True
    elif o[0] in ('-V', '--version'):
        printVersion()
        sys.exit(0)
    elif o[0] in ('-E', '--extractdir'):
        extract_dir = o[1]
        cfg.configuration['ExtractDir'] = extract_dir
    elif o[0] in ('-n', '--noexception'):
        cfg.no_exception = True
    elif o[0] in ('-a', '--all'):
        if '*' not in args:
            args.append('*')
    elif o[0] in ('-f', '--file'):
        cfg.load_config(o[1])
    elif o[0] in ('-o', '--option'):
        kv = o[1].split(None, 1)
        if len(kv) == 1:
            config_overrides[kv[0]] = None
        else:
            config_overrides[kv[0]] = eval(kv[1])

# apply config overrides
for key, value in config_overrides.items():
    cfg.configuration[key] = value

if not extract_dir:
    extract_dir = tempfile.gettempdir()

if info_error: