Example #1
0
    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
Example #2
0
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
Example #3
0
def get_setup_config():
    config = Config(defaults={
        "debug": False,
    })
    try:
        config.from_dict(get_config())
    except FileNotFoundError:
        sys.exit(1)
    return config
Example #4
0
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
Example #5
0
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
Example #6
0
    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())
Example #7
0
    def test_from_yaml(self, get_testing_config):
        conf = Config()
        conf.from_yaml(TESTCONF_PATH)

        assert sorted(conf.items()) == sorted(get_testing_config.items())
Example #8
0
    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())
Example #9
0
 def test_with_default_config(self):
     conf = Config(defaults={"debug": True})
     assert conf["debug"]
Example #10
0
 def test_config(self):
     Config()