The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(model): trim atomic persistence tests to invariants
Teknium1321e71215de
diff --git a/tests/hermes_cli/test_model_selection_atomic_persistence.py b/tests/hermes_cli/test_model_selection_atomic_persistence.pyindex 50efdea324c..95784451e72 100644--- a/tests/hermes_cli/test_model_selection_atomic_persistence.py+++ b/tests/hermes_cli/test_model_selection_atomic_persistence.py@@ -135,89 +135,3 @@ def test_setting_saved_while_route_is_decided_survives(profile_config, monkeypatsaved = yaml.safe_load(profile_config.read_text(encoding="utf-8-sig"))assert wrote and saved["display"]["theme"] == "dark"assert saved["model"] == _EXPECTED---def test_same_route_preserves_raw_references_and_siblings(profile_config):- seed = _SEED.replace(" context_length: 32000\n", "")- profile_config.write_text(seed, encoding="utf-8")- same_route = ModelSwitchResult(- success=True,- new_model="old-model",- target_provider="custom:old",- base_url="https://old.example.test/v1",- api_mode="chat_completions",- is_global=True,- )- persist_model_selection(same_route, profile_config)-- text = profile_config.read_text(encoding="utf-8-sig")- assert yaml.safe_load(text) == yaml.safe_load(seed)- assert "# Keep this header" in text- assert '"keep-this" # Keep this slot' in text- assert '"off" # Keep these quotes' in text- assert "${OLD_MODEL_KEY}" in text and "${VISION_KEY}" in text- assert "synthetic-expanded" not in text---def test_overlapping_process_selection_cannot_leave_a_mixed_route(- profile_config, monkeypatch-):- from hermes_cli import model_switch- import utils-- replace = utils.atomic_replace- intervened = False- child = (- "import sys\n"- "from hermes_cli.model_switch import ModelSwitchResult, persist_model_selection\n"- 'persist_model_selection(ModelSwitchResult(success=True, new_model="other-model", '- 'target_provider="custom:other", base_url="https://other.example.test/v1", '- 'api_mode="chat_completions", is_global=True), sys.argv[1])\n'- )-- def interleave(source, target):- nonlocal intervened- result = replace(source, target)- if Path(target) == profile_config and not intervened:- intervened = True- subprocess.run(- [sys.executable, "-c", child, str(profile_config)],- cwd=Path(model_switch.__file__).resolve().parents[1],- check=True,- capture_output=True,- timeout=60,- creationflags=getattr(subprocess, "CREATE_NO_WINDOW", 0),- )- return result-- monkeypatch.setattr(utils, "atomic_replace", interleave)- persist_model_selection(_RESULT, profile_config)- block = yaml.safe_load(profile_config.read_text(encoding="utf-8-sig"))["model"]- assert block == {- **_EXPECTED,- "default": "other-model",- "provider": "custom:other",- "base_url": "https://other.example.test/v1",- "api_mode": "chat_completions",- }--- "content", ["model: [unterminated\n", "- not-a-config-mapping\n"]-)-def test_unreadable_config_is_not_replaced(profile_config, content):- profile_config.write_text(content, encoding="utf-8")- original = profile_config.read_bytes()- with pytest.raises((yaml.YAMLError, RuntimeError, TypeError)):- persist_model_selection(_RESULT, profile_config)- assert profile_config.read_bytes() == original---def test_missing_config_gets_the_complete_route(profile_config):- profile_config.unlink()- persist_model_selection(_RESULT, profile_config)- assert yaml.safe_load(profile_config.read_text(encoding="utf-8-sig")) == {- "model": {- key: value for key, value in _EXPECTED.items() if key != "model_slots"- },- }