def test_convert_warn(): """ Test conversion from the minimum version supported to the last version supported. """ pre = config.get_config(os.path.join(TESTCONF_PATH, "full", "0.1.yml")) post = config.get_config(os.path.join(TESTCONF_PATH, "full", "0.4.yml")) convert_warn(pre) diff = DeepDiff(pre, post) assert not diff, "diff found between converted config and expected config"
def test_get_config(): config.CONFIG_DIRS = (os.path.join(CUR_PATH, "testconfig"),) + config.CONFIG_DIRS conf = get_config() with open(os.path.join(config.CONFIG_DIRS[0], "config.yml"), "r") as f: expected_conf = yaml.safe_load(f) assert conf == expected_conf
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 test_get_config(): config.CONFIG_DIRS = ( (os.path.join(CUR_PATH, "testconfig"), ) + config.CONFIG_DIRS ) conf = get_config() with open(os.path.join(config.CONFIG_DIRS[0], "config.yml"), "r") as f: expected_conf = yaml.safe_load(f) assert conf == expected_conf
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 get_config(self, config_type: str): path = os.path.join(TESTCONF_PATH, self.target, "{}.yml".format(config_type)) return config.get_config(path)
def test_get_config_not_existing(tmpdir): target_dir = tmpdir.mkdir("no_config") testconf_path = str(target_dir.join("config.yml")) with pytest.raises(FileNotFoundError): get_config(custom_path=testconf_path)
def get_testing_config(): return get_config(custom_path=TESTCONF_PATH)