mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
feat(cron+tests): extend origin fallback to email/dingtalk/qqbot + fix Weixin test mocks
Cron origin fallback extension (builds on #9193's _HOME_TARGET_ENV_VARS): adds the three remaining origin-fallback-eligible platforms that have home channel env vars configured in gateway/config.py but use non-generic env var names: - email → EMAIL_HOME_ADDRESS (non-standard suffix) - dingtalk → DINGTALK_HOME_CHANNEL - qqbot → QQ_HOME_CHANNEL (non-standard prefix: QQ_ not QQBOT_) Picks up the completeness intent of @Xowiek's PR #11317 using the architecturally-correct dict-based lookup from #9193, so platforms with non-standard env var names actually resolve instead of silently missing. Extended the parametrized regression test to cover the new three. Weixin test mock alignment (builds on #10091's _send_session split): Three test sites added in Batch 1 (TestWeixinSendImageFileParameterName) and Batch 3 (TestWeixinVoiceSending) mocked only adapter._session, but #10091 switched the send paths to check self._send_session. Added the companion setter so the tests stay green with the session split in place.
This commit is contained in:
parent
b46db048c3
commit
f64241ed90
3 changed files with 12 additions and 0 deletions
|
|
@ -59,10 +59,13 @@ _HOME_TARGET_ENV_VARS = {
|
||||||
"signal": "SIGNAL_HOME_CHANNEL",
|
"signal": "SIGNAL_HOME_CHANNEL",
|
||||||
"mattermost": "MATTERMOST_HOME_CHANNEL",
|
"mattermost": "MATTERMOST_HOME_CHANNEL",
|
||||||
"sms": "SMS_HOME_CHANNEL",
|
"sms": "SMS_HOME_CHANNEL",
|
||||||
|
"email": "EMAIL_HOME_ADDRESS",
|
||||||
|
"dingtalk": "DINGTALK_HOME_CHANNEL",
|
||||||
"feishu": "FEISHU_HOME_CHANNEL",
|
"feishu": "FEISHU_HOME_CHANNEL",
|
||||||
"wecom": "WECOM_HOME_CHANNEL",
|
"wecom": "WECOM_HOME_CHANNEL",
|
||||||
"weixin": "WEIXIN_HOME_CHANNEL",
|
"weixin": "WEIXIN_HOME_CHANNEL",
|
||||||
"bluebubbles": "BLUEBUBBLES_HOME_CHANNEL",
|
"bluebubbles": "BLUEBUBBLES_HOME_CHANNEL",
|
||||||
|
"qqbot": "QQ_HOME_CHANNEL",
|
||||||
}
|
}
|
||||||
|
|
||||||
from cron.jobs import get_due_jobs, mark_job_run, save_job_output, advance_next_run
|
from cron.jobs import get_due_jobs, mark_job_run, save_job_output, advance_next_run
|
||||||
|
|
|
||||||
|
|
@ -71,9 +71,12 @@ class TestResolveDeliveryTarget:
|
||||||
("signal", "SIGNAL_HOME_CHANNEL", "+15551234567"),
|
("signal", "SIGNAL_HOME_CHANNEL", "+15551234567"),
|
||||||
("mattermost", "MATTERMOST_HOME_CHANNEL", "team-town-square"),
|
("mattermost", "MATTERMOST_HOME_CHANNEL", "team-town-square"),
|
||||||
("sms", "SMS_HOME_CHANNEL", "+15557654321"),
|
("sms", "SMS_HOME_CHANNEL", "+15557654321"),
|
||||||
|
("email", "EMAIL_HOME_ADDRESS", "home@example.com"),
|
||||||
|
("dingtalk", "DINGTALK_HOME_CHANNEL", "cidNNN"),
|
||||||
("feishu", "FEISHU_HOME_CHANNEL", "oc_home"),
|
("feishu", "FEISHU_HOME_CHANNEL", "oc_home"),
|
||||||
("wecom", "WECOM_HOME_CHANNEL", "wecom-home"),
|
("wecom", "WECOM_HOME_CHANNEL", "wecom-home"),
|
||||||
("weixin", "WEIXIN_HOME_CHANNEL", "wxid_home"),
|
("weixin", "WEIXIN_HOME_CHANNEL", "wxid_home"),
|
||||||
|
("qqbot", "QQ_HOME_CHANNEL", "group-openid-home"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_origin_delivery_without_origin_falls_back_to_supported_home_channels(
|
def test_origin_delivery_without_origin_falls_back_to_supported_home_channels(
|
||||||
|
|
@ -88,10 +91,13 @@ class TestResolveDeliveryTarget:
|
||||||
"SIGNAL_HOME_CHANNEL",
|
"SIGNAL_HOME_CHANNEL",
|
||||||
"MATTERMOST_HOME_CHANNEL",
|
"MATTERMOST_HOME_CHANNEL",
|
||||||
"SMS_HOME_CHANNEL",
|
"SMS_HOME_CHANNEL",
|
||||||
|
"EMAIL_HOME_ADDRESS",
|
||||||
|
"DINGTALK_HOME_CHANNEL",
|
||||||
"BLUEBUBBLES_HOME_CHANNEL",
|
"BLUEBUBBLES_HOME_CHANNEL",
|
||||||
"FEISHU_HOME_CHANNEL",
|
"FEISHU_HOME_CHANNEL",
|
||||||
"WECOM_HOME_CHANNEL",
|
"WECOM_HOME_CHANNEL",
|
||||||
"WEIXIN_HOME_CHANNEL",
|
"WEIXIN_HOME_CHANNEL",
|
||||||
|
"QQ_HOME_CHANNEL",
|
||||||
):
|
):
|
||||||
monkeypatch.delenv(fallback_env, raising=False)
|
monkeypatch.delenv(fallback_env, raising=False)
|
||||||
monkeypatch.setenv(env_var, chat_id)
|
monkeypatch.setenv(env_var, chat_id)
|
||||||
|
|
|
||||||
|
|
@ -527,6 +527,7 @@ class TestWeixinSendImageFileParameterName:
|
||||||
"""Verify send_image_file accepts image_path and forwards to send_document."""
|
"""Verify send_image_file accepts image_path and forwards to send_document."""
|
||||||
adapter = _make_adapter()
|
adapter = _make_adapter()
|
||||||
adapter._session = object()
|
adapter._session = object()
|
||||||
|
adapter._send_session = adapter._session
|
||||||
adapter._token = "test-token"
|
adapter._token = "test-token"
|
||||||
|
|
||||||
send_document_mock.return_value = weixin.SendResult(success=True, message_id="test-id")
|
send_document_mock.return_value = weixin.SendResult(success=True, message_id="test-id")
|
||||||
|
|
@ -554,6 +555,7 @@ class TestWeixinSendImageFileParameterName:
|
||||||
"""Verify send_image_file works with minimal required params."""
|
"""Verify send_image_file works with minimal required params."""
|
||||||
adapter = _make_adapter()
|
adapter = _make_adapter()
|
||||||
adapter._session = object()
|
adapter._session = object()
|
||||||
|
adapter._send_session = adapter._session
|
||||||
adapter._token = "test-token"
|
adapter._token = "test-token"
|
||||||
|
|
||||||
send_document_mock.return_value = weixin.SendResult(success=True, message_id="test-id")
|
send_document_mock.return_value = weixin.SendResult(success=True, message_id="test-id")
|
||||||
|
|
@ -578,6 +580,7 @@ class TestWeixinVoiceSending:
|
||||||
def _connected_adapter(self) -> WeixinAdapter:
|
def _connected_adapter(self) -> WeixinAdapter:
|
||||||
adapter = _make_adapter()
|
adapter = _make_adapter()
|
||||||
adapter._session = object()
|
adapter._session = object()
|
||||||
|
adapter._send_session = adapter._session
|
||||||
adapter._token = "test-token"
|
adapter._token = "test-token"
|
||||||
adapter._base_url = "https://weixin.example.com"
|
adapter._base_url = "https://weixin.example.com"
|
||||||
adapter._token_store.get = lambda account_id, chat_id: "ctx-token"
|
adapter._token_store.get = lambda account_id, chat_id: "ctx-token"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue