mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
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:
parent
287d3e12c7
commit
103beea7a6
3 changed files with 6 additions and 3 deletions
|
|
@ -20,6 +20,7 @@ from .adapter import ( # noqa: F401
|
|||
QQCloseError,
|
||||
check_qq_requirements,
|
||||
_coerce_list,
|
||||
_ssrf_redirect_guard,
|
||||
)
|
||||
|
||||
# -- Onboard (QR-code scan-to-configure) -----------------------------------
|
||||
|
|
@ -40,6 +41,7 @@ __all__ = [
|
|||
"QQCloseError",
|
||||
"check_qq_requirements",
|
||||
"_coerce_list",
|
||||
"_ssrf_redirect_guard",
|
||||
# onboard
|
||||
"BindStatus",
|
||||
"create_bind_task",
|
||||
|
|
|
|||
|
|
@ -766,7 +766,7 @@ class QQAdapter(BasePlatformAdapter):
|
|||
try:
|
||||
payload = json.loads(raw)
|
||||
except Exception:
|
||||
logger.debug("[%s] Failed to parse JSON: %r", self._log_tag, raw)
|
||||
logger.warning("[QQBot] Failed to parse JSON: %r", raw)
|
||||
return None
|
||||
return payload if isinstance(payload, dict) else None
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue