示例#1
0
def test_merge_settings_p03_set_defaults_all():
    default_args = {
        'arg1': 'arg1',
        'arg2': 'arg2',
    }
    vargs = kvargs.merge_settings({}, args_default=default_args)
    assert vargs == default_args
示例#2
0
def test_merge_settings_p01_conf_in_conf():
    args = {
        'setting1': None,
        'setting2': None,
        'setting3': 'start3',
    }
    finalconf = {
        'setting1': 'middle1',
        'setting2': 'middle2',
        'setting3': 'start3',
        'conf': 'kvargs2.json',
        'conf_files_loaded': ['kvargs1.json', 'kvargs2.json'],
    }

    with open(conf, 'w') as f:
        json.dump(conf1, f)
    with open(conf1['conf'], 'w') as f:
        json.dump(conf2, f)

    vargs = kvargs.merge_settings(args, conf, args_default)

    assert vargs == finalconf

    os.unlink(conf)
    os.unlink(conf1['conf'])
示例#3
0
def test_merge_settings_p04_set_defaults_some():
    default_args = {
        'arg1': 'arg1',
        'arg2': 'arg2',
    }
    vargs = kvargs.merge_settings({'arg1': 'not_default'},
                                  args_default=default_args)
    default_args['arg1'] = 'not_default'
    assert vargs == default_args
示例#4
0
def test_merge_settings_p04_all_set_cmd_line():
    args = {
        'setting1': 'cmd1',
        'setting2': 'cmd2',
        'setting3': 'cmd3',
    }
    finalconf = args
    finalconf['conf_files_loaded'] = []

    vargs = kvargs.merge_settings(args, '', args_default)

    assert vargs == finalconf
示例#5
0
def test_merge_settings_p03_set_by_default_no_conf_no_value():
    args = {
        'setting3': 'start3',
    }
    finalconf = {
        'setting1': 'start1',
        'setting2': 'start2',
        'setting3': 'start3',
    }

    vargs = kvargs.merge_settings(args, '', args_default)

    assert dict(vargs) == finalconf
示例#6
0
def test_merge_settings_p04_set_by_default_no_conf_blank_value():
    args = {
        'setting1': '',
        'setting3': 'start3',
    }
    finalconf = {
        'setting1': '',
        'setting2': 'start2',
        'setting3': 'start3',
    }

    vargs = kvargs.merge_settings(args, '', args_default)

    assert vargs == finalconf
示例#7
0
def test_merge_settings_p02_args_dict():
    vargs = kvargs.merge_settings({})
    assert vargs == {}