def merging_can_be_deferred(self): c = Config() assert "foo" not in c._collection assert "foo" not in c c.load_collection({"foo": "bar"}, merge=False) assert "foo" in c._collection assert "foo" not in c
def performed_explicitly_and_directly(self): # TODO: do we want to update the other levels to allow 'direct' # loading like this, now that they all have explicit methods? c = Config() assert "foo" not in c c.load_collection({"foo": "bar"}) assert c.foo == "bar"
def runtime_overrides_collection(self): c = Config(runtime_path=join(CONFIGS_PATH, "json", "raft.json")) c.load_collection({"outer": {"inner": {"hooray": "defaults"}}}) c.load_runtime() assert c.outer.inner.hooray == "json"
def env_vars_override_collection(self): os.environ["RAFT_OUTER_INNER_HOORAY"] = "env" c = Config() c.load_collection({"outer": {"inner": {"hooray": "defaults"}}}) c.load_shell_env() assert c.outer.inner.hooray == "env"
def project_overrides_collection(self): c = Config(project_location=join(CONFIGS_PATH, "yaml")) c.load_project() c.load_collection({"outer": {"inner": {"hooray": "defaults"}}}) assert c.outer.inner.hooray == "yaml"
def user_overrides_collection(self): c = Config(user_prefix=join(CONFIGS_PATH, "json/")) c.load_collection({"outer": {"inner": {"hooray": "defaults"}}}) assert c.outer.inner.hooray == "json"
def systemwide_overrides_collection(self): c = Config(system_prefix=join(CONFIGS_PATH, "yaml/")) c.load_collection({"outer": {"inner": {"hooray": "defaults"}}}) assert c.outer.inner.hooray == "yaml"
def collection_overrides_defaults(self): c = Config(defaults={"nested": {"setting": "default"}}) c.load_collection({"nested": {"setting": "collection"}}) assert c.nested.setting == "collection"