claire/tests/test_agent_config.py
Natalie 3057182717 feat(@projects/@claire): add headless peer sync agent loops
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-05-31 18:15:59 -06:00

27 lines
972 B
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)}
)
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.port == 8766 # default preserved across round-trip