ria-toolkit-oss/tests/agent/test_config.py
2026-04-13 11:48:15 -04:00

34 lines
907 B
Python

from ria_toolkit_oss.agent import config as agent_config
def test_round_trip(tmp_path):
p = tmp_path / "agent.json"
cfg = agent_config.AgentConfig(
hub_url="https://hub.example.com",
agent_id="agent-1",
token="t",
name="bench",
insecure=True,
)
agent_config.save(cfg, path=p)
loaded = agent_config.load(path=p)
assert loaded == cfg
def test_load_missing_returns_empty(tmp_path):
loaded = agent_config.load(path=tmp_path / "none.json")
assert loaded == agent_config.AgentConfig()
def test_extra_keys_preserved(tmp_path):
p = tmp_path / "agent.json"
p.write_text('{"hub_url": "x", "custom": 42}')
cfg = agent_config.load(path=p)
assert cfg.hub_url == "x"
assert cfg.extra == {"custom": 42}
agent_config.save(cfg, path=p)
import json
data = json.loads(p.read_text())
assert data["custom"] == 42