def test_mapping_list_config_file(option, value, expect): config = Config(env_prefix="ARCHIVEMATICA_DASHBOARD", attrs=CONFIG_MAPPING) config.read_defaults( StringIO.StringIO("[Dashboard]\n" "{option} = {value}".format(option=option, value=value))) if isinstance(expect, list): assert sorted(config.get("search_enabled")) == sorted(expect) else: with pytest.raises(expect): config.get("search_enabled")
def test_mapping_list_env_var(envvars, expect): for var, val in envvars.items(): os.environ[var] = val config = Config(env_prefix="ARCHIVEMATICA_DASHBOARD", attrs=CONFIG_MAPPING) if isinstance(expect, list): assert sorted(config.get("search_enabled")) == sorted(expect) else: with pytest.raises(expect): config.get("search_enabled") for var in envvars: del os.environ[var]
def test_mapping_list_env_var(envvars, expect): for var, val in envvars.items(): os.environ[var] = val config = Config(env_prefix='ARCHIVEMATICA_DASHBOARD', attrs=CONFIG_MAPPING) if bool(expect) is expect: search_enabled = config.get('search_enabled') assert search_enabled is expect else: with pytest.raises(expect): config.get('search_enabled') for var in envvars: del os.environ[var]
def test_mapping_list_config_file(option, value, expect): config = Config(env_prefix='ARCHIVEMATICA_DASHBOARD', attrs=CONFIG_MAPPING) config.read_defaults(StringIO.StringIO( '[Dashboard]\n' '{option} = {value}'.format(option=option, value=value))) assert config.get('search_enabled') is expect