mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-04 02:21:47 +00:00
Automated dead code audit using vulture + coverage.py + ast-grep intersection, confirmed by Opus deep verification pass. Every symbol verified to have zero production callers (test imports excluded from reachability analysis). Removes ~1,534 lines of dead production code across 46 files and ~1,382 lines of stale test code. 3 entire files deleted (agent/builtin_memory_provider.py, hermes_cli/checklist.py, tests/hermes_cli/test_setup_model_selection.py). Co-authored-by: alt-glitch <balyan.sid@gmail.com>
74 lines
2.7 KiB
Python
74 lines
2.7 KiB
Python
"""Tests for the delivery routing module."""
|
|
|
|
from gateway.config import Platform, GatewayConfig, PlatformConfig, HomeChannel
|
|
from gateway.delivery import DeliveryRouter, DeliveryTarget
|
|
from gateway.session import SessionSource
|
|
|
|
|
|
class TestParseTargetPlatformChat:
|
|
def test_explicit_telegram_chat(self):
|
|
target = DeliveryTarget.parse("telegram:12345")
|
|
assert target.platform == Platform.TELEGRAM
|
|
assert target.chat_id == "12345"
|
|
assert target.is_explicit is True
|
|
|
|
def test_platform_only_no_chat_id(self):
|
|
target = DeliveryTarget.parse("discord")
|
|
assert target.platform == Platform.DISCORD
|
|
assert target.chat_id is None
|
|
assert target.is_explicit is False
|
|
|
|
def test_local_target(self):
|
|
target = DeliveryTarget.parse("local")
|
|
assert target.platform == Platform.LOCAL
|
|
assert target.chat_id is None
|
|
|
|
def test_origin_with_source(self):
|
|
origin = SessionSource(platform=Platform.TELEGRAM, chat_id="789", thread_id="42")
|
|
target = DeliveryTarget.parse("origin", origin=origin)
|
|
assert target.platform == Platform.TELEGRAM
|
|
assert target.chat_id == "789"
|
|
assert target.thread_id == "42"
|
|
assert target.is_origin is True
|
|
|
|
def test_origin_without_source(self):
|
|
target = DeliveryTarget.parse("origin")
|
|
assert target.platform == Platform.LOCAL
|
|
assert target.is_origin is True
|
|
|
|
def test_unknown_platform(self):
|
|
target = DeliveryTarget.parse("unknown_platform")
|
|
assert target.platform == Platform.LOCAL
|
|
|
|
|
|
class TestTargetToStringRoundtrip:
|
|
def test_origin_roundtrip(self):
|
|
origin = SessionSource(platform=Platform.TELEGRAM, chat_id="111", thread_id="42")
|
|
target = DeliveryTarget.parse("origin", origin=origin)
|
|
assert target.to_string() == "origin"
|
|
|
|
def test_local_roundtrip(self):
|
|
target = DeliveryTarget.parse("local")
|
|
assert target.to_string() == "local"
|
|
|
|
def test_platform_only_roundtrip(self):
|
|
target = DeliveryTarget.parse("discord")
|
|
assert target.to_string() == "discord"
|
|
|
|
def test_explicit_chat_roundtrip(self):
|
|
target = DeliveryTarget.parse("telegram:999")
|
|
s = target.to_string()
|
|
assert s == "telegram:999"
|
|
|
|
reparsed = DeliveryTarget.parse(s)
|
|
assert reparsed.platform == Platform.TELEGRAM
|
|
assert reparsed.chat_id == "999"
|
|
|
|
|
|
class TestDeliveryRouter:
|
|
def test_resolve_targets_does_not_duplicate_local_when_explicit(self):
|
|
router = DeliveryRouter(GatewayConfig(always_log_local=True))
|
|
|
|
targets = router.resolve_targets(["local"])
|
|
|
|
assert [target.platform for target in targets] == [Platform.LOCAL]
|