示例#1
0
def main():
    """
    Fetch parameter from config file or environment variables
    """
    parser = ArgumentParser()
    parser.add_argument('config_file', help='Config file name')
    parser.add_argument('section', help='Section name')
    parser.add_argument('parameter', help='Argument name')
    parser.add_argument('-o',
                        '--override-file',
                        help='Config file override file name')
    args = parser.parse_args()

    configular = Configular(args.config_file,
                            override_filename=args.override_file)
    print(configular.get(args.section, args.parameter))
示例#2
0
def test_no_override_file():
    config = Configular(CONFIG_FILE)
    assert config.get('Github', 'client_id') == 'irregular'
示例#3
0
def test_config_override_to_empty(config: Configular):
    assert config.get('Github', 'client_id') == 'irregular'
示例#4
0
def test_all_empty(config: Configular):
    with pytest.raises(ParameterNotFoundException):
        config.get('EmptyValue', 'nothing_here')
示例#5
0
def test_config_override(config: Configular):
    assert config.get('Github', 'password') == 'xyz789'
示例#6
0
def test_config_override_from_empty(config: Configular):
    assert config.get('Github', 'token') == 'whenislunch'
示例#7
0
def test_env_var_override_from_empty(config: Configular):
    assert config.get('Github', 'instance_id') == 'irregularengineering'
示例#8
0
def test_env_var_override_to_empty(config: Configular):
    assert config.get('Github', 'username') == 'bojack'
示例#9
0
def test_not_found_no_throw():
    config = Configular(CONFIG_FILE,
                        override_filename=OVERRIDE_FILE,
                        raise_on_not_found=False)
    assert not config.get('BananaStand', 'money')
示例#10
0
def test_env_var_override(config: Configular):
    assert config.get('JIRA', 'api_key') == 'yayjirayay'
示例#11
0
def test_not_found(config: Configular):
    with pytest.raises(ParameterNotFoundException):
        config.get('BananaStand', 'money')
示例#12
0
def test_override_only(config: Configular):
    assert config.get('Salesforce', 'api_key') == 'notagoodkey'
示例#13
0
def test_config_only(config: Configular):
    assert config.get('Github', 'username') == 'bojack'
示例#14
0
def test_env_var_only(config: Configular):
    assert config.get('Slack', 'token') == 'yowutup'
示例#15
0
def config():
    return Configular(CONFIG_FILE, override_filename=OVERRIDE_FILE)