Kill the mutants of do_epic/config.py that its tests missed
CI / tests (pull_request) Successful in 3m2s
CI / tests (pull_request) Successful in 3m2s
This commit is contained in:
@@ -54,11 +54,11 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi
|
||||
if isinstance(ladder, Failure):
|
||||
return ladder
|
||||
models = sorted({rung.model for rung in ladder.rungs})
|
||||
rule: str | Failure
|
||||
try:
|
||||
rule = (folder / REPO_RULE).read_text(encoding="utf-8")
|
||||
unread = None
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
rule, unread = "", f"cannot read {folder / REPO_RULE}: {failure}"
|
||||
rule = Failure(f"cannot read {folder / REPO_RULE}: {failure}")
|
||||
config_folders = [path for path in (home / PROJECTS).iterdir() if path.is_dir()]
|
||||
clone_folder = anywhere(values.get(CLONE_FOLDER, "~/code"), home)
|
||||
env_file = anywhere(values.get(ENV_FILE), home)
|
||||
@@ -73,10 +73,10 @@ def load(home: pathlib.Path, ladder_file: pathlib.Path = SHIPPED) -> DoEpicConfi
|
||||
*([f"`{ENV_FILE}` is {values[ENV_FILE]!r}, inside a folder of ~/{PROJECTS} or the clone folder, which hold git checkouts"] if env_file and lies_in(env_file, *config_folders, *([clone_folder] if clone_folder else [])) else []),
|
||||
*([f"`{LANGUAGE}` is {language!r}, {fault}"] if LANGUAGE in values and (fault := language_fault(language)) else []),
|
||||
*([f"`{REPOLESS_MODEL}` is {model!r}, not a model on the routing ladder: {', '.join(models)}"] if REPOLESS_MODEL in values and model not in models else []),
|
||||
*([unread] if unread else [f"`{REPO_RULE}` is blank"] if not rule.strip() else []),
|
||||
*([rule.reason] if isinstance(rule, Failure) else [f"`{REPO_RULE}` is blank"] if not rule.strip() else []),
|
||||
]
|
||||
if faults:
|
||||
return Failure(f"{folder}: {'; '.join(faults)}. {LISTED}")
|
||||
# Without a fault, each value above is present and of the type asserted here.
|
||||
assert clone_folder and env_file and isinstance(url, str) and isinstance(model, str) and isinstance(language, str)
|
||||
assert clone_folder and env_file and isinstance(url, str) and isinstance(model, str) and isinstance(language, str) and isinstance(rule, str)
|
||||
return DoEpicConfig(folder, url, env_file, clone_folder, language, model, rule)
|
||||
|
||||
@@ -115,3 +115,18 @@ class ConfigTest(unittest.TestCase):
|
||||
reason = self.failure()
|
||||
for part in ("`jira-url` is", "`env-file` is missing", "`repoless-model` is"):
|
||||
self.assertIn(part, reason)
|
||||
self.assertIn("`env-file` is missing; `jira-url` is", reason, "joined by semicolons")
|
||||
|
||||
def test_names_the_models_on_the_ladder_where_the_model_is_off_it(self) -> None:
|
||||
ladder = self.home / "ladder.json"
|
||||
ladder.write_text('[{"model": "claude-sonnet-5-5", "effort": "low"}, {"model": "claude-opus-5-5", "effort": "low"}]', encoding="utf-8")
|
||||
self.write(SETTINGS.replace("claude-opus-5-5", "claude-haiku-5-5"))
|
||||
found = load(self.home, ladder)
|
||||
assert isinstance(found, Failure), found
|
||||
self.assertIn("not a model on the routing ladder: claude-opus-5-5, claude-sonnet-5-5.", found.reason)
|
||||
|
||||
def test_reads_the_rule_and_the_settings_as_utf8(self) -> None:
|
||||
self.write(SETTINGS + 'language = "Svenska"\n', rule="Etiketten är repots namn.\n")
|
||||
found = load(self.home)
|
||||
assert isinstance(found, DoEpicConfig), found
|
||||
self.assertEqual(found.repo_rule, "Etiketten är repots namn.\n")
|
||||
|
||||
Reference in New Issue
Block a user