fix(qqbot): fix test failures after package refactor

- Re-export _ssrf_redirect_guard from __init__.py
- Fix _parse_json @staticmethod using self._log_tag
- Update test_detect_message_type to call as instance method
- Fix mock.patch path for httpx.AsyncClient in adapter submodule
This commit is contained in:
WideLee
2026-04-17 20:42:41 +08:00
committed by Teknium
parent 287d3e12c7
commit 103beea7a6
3 changed files with 6 additions and 3 deletions

View File

@@ -179,7 +179,7 @@ class TestVoiceAttachmentSSRFProtection:
from gateway.platforms.qqbot import QQAdapter, _ssrf_redirect_guard
client = mock.AsyncMock()
with mock.patch("gateway.platforms.qqbot.httpx.AsyncClient", return_value=client) as async_client_cls:
with mock.patch("gateway.platforms.qqbot.adapter.httpx.AsyncClient", return_value=client) as async_client_cls:
adapter = QQAdapter(_make_config(app_id="a", client_secret="b"))
adapter._ensure_token = mock.AsyncMock(side_effect=RuntimeError("stop after client creation"))
@@ -316,7 +316,8 @@ class TestResolveSTTConfig:
class TestDetectMessageType:
def _fn(self, media_urls, media_types):
from gateway.platforms.qqbot import QQAdapter
return QQAdapter._detect_message_type(media_urls, media_types)
adapter = QQAdapter(_make_config(app_id="a", client_secret="b"))
return adapter._detect_message_type(media_urls, media_types)
def test_no_media(self):
from gateway.platforms.base import MessageType