from __future__ import annotations from pathlib import Path from syncgames.config import AgentConfig, save_agent_config, try_load_agent_config def test_save_and_reload_agent(tmp_path: Path, monkeypatch): monkeypatch.setenv("SYNCGAMES_CONFIG", str(tmp_path)) cfg = AgentConfig( device_id="laptop", endpoint_url="https://syncgames-s3.example.com", bucket="syncgames", access_key="ak", secret_key="sk", config_root=tmp_path, ) path = save_agent_config(cfg) assert path.exists() loaded = try_load_agent_config(tmp_path) assert loaded is not None assert loaded.device_id == "laptop" assert loaded.endpoint_url.endswith("example.com") assert loaded.secret_key == "sk"