claire/tests/test_agent_config.py
Natalie 2146e42de7 feat(@projects/@claire): add auto-continue nudge logic
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-06-01 00:39:02 -06:00

30 lines
1.1 KiB
Python

"""AgentConfig serialize/deserialize round-trip via the hand-rolled _serialize."""
from __future__ import annotations
from pathlib import Path
from claire.config import AgentConfig, ClaireConfig, _serialize, load_or_init
def test_agent_section_omitted_when_default() -> None:
cfg = ClaireConfig(machine_id="m")
assert "[agent]" not in _serialize(cfg)
def test_agent_config_roundtrip(tmp_path: Path) -> None:
p = tmp_path / "claire.toml"
cfg = load_or_init(p) # fresh: mints machine_id + sync_secret, writes file
mutated = cfg.model_copy(
update={"agent": AgentConfig(
sync_interval_s=30, supervisor_allow_respawn=True, auto_continue="dry-run"
)}
)
p.write_text(_serialize(mutated), encoding="utf-8")
reloaded = load_or_init(p)
assert "[agent]" in p.read_text()
assert reloaded.agent.sync_interval_s == 30
assert reloaded.agent.supervisor_allow_respawn is True
assert reloaded.agent.auto_continue == "dry-run" # guards _serialize coverage
assert reloaded.agent.port == 8766 # default preserved across round-trip