test: cover archived heartbeat target selection

This commit is contained in:
Xubin Ren
2026-06-24 15:45:49 +08:00
parent de4009efbd
commit c915e98c15
4 changed files with 45 additions and 20 deletions
+15
View File
@@ -1247,6 +1247,21 @@ def test_heartbeat_skips_bundled_template():
assert _heartbeat_has_active_tasks(load_bundled_template("HEARTBEAT.md")) is False
def test_heartbeat_target_skips_archived_webui_sessions():
from nanobot.cli.commands import _pick_heartbeat_target_from_sessions
target = _pick_heartbeat_target_from_sessions(
enabled_channels=["websocket"],
archived_keys=["websocket:archived"],
sessions=[
{"key": "websocket:archived"},
{"key": "websocket:active"},
],
)
assert target == ("websocket", "active")
def _write_instance_config(tmp_path: Path) -> Path:
config_file = tmp_path / "instance" / "config.json"
config_file.parent.mkdir(parents=True)