test(dingtalk): cover get_connected_platforms + null platform_toolsets

Follow-ups to the salvaged commits in this PR:

* gateway/config.py — strip trailing whitespace from youngDoo's diff
  (line 315 had ~140 trailing spaces).

* hermes_cli/tools_config.py — replace `config.get("platform_toolsets", {})`
  with `config.get("platform_toolsets") or {}`. Handles the case where the
  YAML key is present but explicitly null (parses as None, previously
  crashed with AttributeError on the next line's .get(platform)).
  Cherry-picked from yyq4193's #9003 with attribution.

* tests/gateway/test_config.py — 4 new tests for TestGetConnectedPlatforms
  covering DingTalk via extras, via env vars, disabled, and missing creds.

* tests/hermes_cli/test_tools_config.py — regression test for the null
  platform_toolsets edge case.

* scripts/release.py — add kagura-agent, youngDoo, yyq4193 to AUTHOR_MAP.

Co-authored-by: yyq4193 <39405770+yyq4193@users.noreply.github.com>
This commit is contained in:
Teknium 2026-04-17 05:40:44 -07:00 committed by Teknium
parent 47a0dd1024
commit c60b6dc317
5 changed files with 62 additions and 2 deletions

View file

@ -71,6 +71,51 @@ class TestGetConnectedPlatforms:
config = GatewayConfig()
assert config.get_connected_platforms() == []
def test_dingtalk_recognised_via_extras(self):
config = GatewayConfig(
platforms={
Platform.DINGTALK: PlatformConfig(
enabled=True,
extra={"client_id": "cid", "client_secret": "sec"},
),
},
)
assert Platform.DINGTALK in config.get_connected_platforms()
def test_dingtalk_recognised_via_env_vars(self, monkeypatch):
"""DingTalk configured via env vars (no extras) should still be
recognised as connected covers the case where _apply_env_overrides
hasn't populated extras yet."""
monkeypatch.setenv("DINGTALK_CLIENT_ID", "env_cid")
monkeypatch.setenv("DINGTALK_CLIENT_SECRET", "env_sec")
config = GatewayConfig(
platforms={
Platform.DINGTALK: PlatformConfig(enabled=True, extra={}),
},
)
assert Platform.DINGTALK in config.get_connected_platforms()
def test_dingtalk_missing_creds_not_connected(self, monkeypatch):
monkeypatch.delenv("DINGTALK_CLIENT_ID", raising=False)
monkeypatch.delenv("DINGTALK_CLIENT_SECRET", raising=False)
config = GatewayConfig(
platforms={
Platform.DINGTALK: PlatformConfig(enabled=True, extra={}),
},
)
assert Platform.DINGTALK not in config.get_connected_platforms()
def test_dingtalk_disabled_not_connected(self):
config = GatewayConfig(
platforms={
Platform.DINGTALK: PlatformConfig(
enabled=False,
extra={"client_id": "cid", "client_secret": "sec"},
),
},
)
assert Platform.DINGTALK not in config.get_connected_platforms()
class TestSessionResetPolicy:
def test_roundtrip(self):