def test_get_groups(self, get_testing_config): conf = Config() conf["default"] = {"daily": 4} conf["groups"] = {"test_group": {"daily": 3, }, } groups = conf.get_groups() assert groups["test_group"]["daily"] == 3
def mock_get_config(monkeypatch): config = Config(defaults={"debug": False, }) config.from_dict(get_config(TESTCONF_PATH)) monkeypatch.setattr( virt_backup.__main__, "get_setup_config", lambda: config ) return config
def get_setup_config(): config = Config(defaults={ "debug": False, }) try: config.from_dict(get_config()) except FileNotFoundError: sys.exit(1) return config
def mock_get_config(monkeypatch): config = Config(defaults={ "debug": False, }) config.from_dict(get_config(TESTCONF_PATH)) monkeypatch.setattr(virt_backup.__main__, "get_setup_config", lambda: config) return config
def get_setup_config(): config = Config(defaults={"debug": False,}) try: loaded_config = get_config() except FileNotFoundError: sys.exit(1) compat_layers.config.convert_warn(loaded_config) config.from_dict(loaded_config) return config
def test_from_str(self, get_testing_config): conf = Config() with open(TESTCONF_PATH, "r") as conf_file: conf.from_str(conf_file.read()) assert sorted(conf.items()) == sorted(get_testing_config.items())
def test_from_yaml(self, get_testing_config): conf = Config() conf.from_yaml(TESTCONF_PATH) assert sorted(conf.items()) == sorted(get_testing_config.items())
def test_from_dict(self, get_testing_config): conf = Config() conf.from_dict(get_testing_config) assert sorted(conf.items()) == sorted(get_testing_config.items())
def test_with_default_config(self): conf = Config(defaults={"debug": True}) assert conf["debug"]
def test_config(self): Config()