Example #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))
Example #2
0
def test_no_override_file():
    config = Configular(CONFIG_FILE)
    assert config.get('Github', 'client_id') == 'irregular'
Example #3
0
def test_config_override_to_empty(config: Configular):
    assert config.get('Github', 'client_id') == 'irregular'
Example #4
0
def test_all_empty(config: Configular):
    with pytest.raises(ParameterNotFoundException):
        config.get('EmptyValue', 'nothing_here')
Example #5
0
def test_config_override(config: Configular):
    assert config.get('Github', 'password') == 'xyz789'
Example #6
0
def test_config_override_from_empty(config: Configular):
    assert config.get('Github', 'token') == 'whenislunch'
Example #7
0
def test_env_var_override_from_empty(config: Configular):
    assert config.get('Github', 'instance_id') == 'irregularengineering'
Example #8
0
def test_env_var_override_to_empty(config: Configular):
    assert config.get('Github', 'username') == 'bojack'
Example #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')
Example #10
0
def test_env_var_override(config: Configular):
    assert config.get('JIRA', 'api_key') == 'yayjirayay'
Example #11
0
def test_not_found(config: Configular):
    with pytest.raises(ParameterNotFoundException):
        config.get('BananaStand', 'money')
Example #12
0
def test_override_only(config: Configular):
    assert config.get('Salesforce', 'api_key') == 'notagoodkey'
Example #13
0
def test_config_only(config: Configular):
    assert config.get('Github', 'username') == 'bojack'
Example #14
0
def test_env_var_only(config: Configular):
    assert config.get('Slack', 'token') == 'yowutup'
Example #15
0
def config():
    return Configular(CONFIG_FILE, override_filename=OVERRIDE_FILE)