Esempio n. 1
0
 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"
Esempio n. 2
0
 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"
Esempio n. 3
0
 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"
Esempio n. 4
0
 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)
Esempio n. 5
0
 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
Esempio n. 6
0
 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"
Esempio n. 7
0
 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"
Esempio n. 8
0
 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()
Esempio n. 9
0
 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.")
Esempio n. 10
0
 def unknown_suffix_in_runtime_path_raises_useful_error(self):
     c = Config(runtime_path=join(CONFIGS_PATH, "screw.ini"))
     c.load_runtime()
Esempio n. 11
0
 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"