test(feishu): 修正 token 刷新测试 mock

This commit is contained in:
2026-06-07 22:43:40 +08:00
parent 90144c42ac
commit 1f56247978

View File

@@ -173,8 +173,6 @@ def test_send_personal_message_api_error(monkeypatch, settings):
def test_send_personal_message_refreshes_token_once(monkeypatch, settings): def test_send_personal_message_refreshes_token_once(monkeypatch, settings):
settings.FEISHU_MESSAGE_API_URL = "http://feishu/messages" settings.FEISHU_MESSAGE_API_URL = "http://feishu/messages"
settings.FEISHU_APP_ID = "cli_a"
settings.FEISHU_APP_SECRET = "secret"
calls = {"message": 0} calls = {"message": 0}
def fake_message_post(*args, **kwargs): def fake_message_post(*args, **kwargs):
@@ -185,8 +183,12 @@ def test_send_personal_message_refreshes_token_once(monkeypatch, settings):
monkeypatch.setattr("review_agent.notifications.feishu_message_api.httpx.post", fake_message_post) monkeypatch.setattr("review_agent.notifications.feishu_message_api.httpx.post", fake_message_post)
monkeypatch.setattr( monkeypatch.setattr(
"review_agent.notifications.feishu_token.httpx.post", "review_agent.notifications.feishu_message_api.get_tenant_access_token",
lambda *args, **kwargs: FakeResponse({"code": 0, "tenant_access_token": "fresh", "expire": 7200}), lambda force_refresh=False: type(
"TokenResult",
(),
{"ok": True, "tenant_access_token": "fresh", "error_code": "", "error_message": ""},
)(),
) )
result = send_personal_message( result = send_personal_message(