def runtime_overrides_systemwide(self): c = Config( runtime_path=join(CONFIGS_PATH, "json", "raft.json"), system_prefix=join(CONFIGS_PATH, "yaml/"), ) c.load_runtime() assert c.outer.inner.hooray == "json"
def runtime_overrides_project(self): c = Config( runtime_path=join(CONFIGS_PATH, "json", "raft.json"), project_location=join(CONFIGS_PATH, "yaml"), ) c.load_runtime() c.load_project() assert c.outer.inner.hooray == "json"
def cli_overrides_override_all(self): "CLI-driven overrides win vs all other layers" # TODO: expand into more explicit tests like the above? meh c = Config( overrides={"outer": {"inner": {"hooray": "overrides"}}}, runtime_path=join(CONFIGS_PATH, "json", "raft.json"), ) c.load_runtime() assert c.outer.inner.hooray == "overrides"
def python_modules_except_usefully_on_unpicklable_modules(self): # Re: #556; when bug present, a TypeError pops up instead (granted, # at merge time, but we want it to raise ASAP, so we're testing the # intended new behavior: raising at config load time. c = Config() c.set_runtime_path(join(support, "has_modules.py")) expected = r"'os' is a module.*giving a tasks file.*mistake" with pytest.raises(UnpicklableConfigMember, match=expected): c.load_runtime(merge=False)
def runtime_can_skip_merging(self): path = join(CONFIGS_PATH, "yaml", "raft.yaml") config = Config(runtime_path=path, lazy=True) assert "outer" not in config._runtime assert "outer" not in config config.load_runtime(merge=False) # Test that we loaded into the per-level dict, but not the # central/merged config. assert "outer" in config._runtime assert "outer" not in config
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 runtime_overrides_env_vars(self): os.environ["RAFT_OUTER_INNER_HOORAY"] = "env" c = Config(runtime_path=join(CONFIGS_PATH, "json", "raft.json")) c.load_runtime() c.load_shell_env() assert c.outer.inner.hooray == "json"
def non_missing_file_IOErrors_are_raised(self): c = Config() c._load_yml = Mock(side_effect=IOError(17, "uh, what?")) c.set_runtime_path("is-a.yml") # Triggers use of _load_yml c.load_runtime()
def nonexistent_files_are_skipped_and_logged(self, mock_debug): c = Config() c._load_yml = Mock(side_effect=IOError(2, "aw nuts")) c.set_runtime_path("is-a.yml") # Triggers use of _load_yml c.load_runtime() mock_debug.assert_any_call("Didn't see any is-a.yml, skipping.")
def unknown_suffix_in_runtime_path_raises_useful_error(self): c = Config(runtime_path=join(CONFIGS_PATH, "screw.ini")) c.load_runtime()
def runtime_conf_via_cli_flag(self): c = Config(runtime_path=join(CONFIGS_PATH, "yaml", "raft.yaml")) c.load_runtime() assert c.outer.inner.hooray == "yaml"