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