test(feishu): 修正 token 刷新测试 mock
This commit is contained in:
@@ -173,8 +173,6 @@ def test_send_personal_message_api_error(monkeypatch, settings):
|
||||
|
||||
def test_send_personal_message_refreshes_token_once(monkeypatch, settings):
|
||||
settings.FEISHU_MESSAGE_API_URL = "http://feishu/messages"
|
||||
settings.FEISHU_APP_ID = "cli_a"
|
||||
settings.FEISHU_APP_SECRET = "secret"
|
||||
calls = {"message": 0}
|
||||
|
||||
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_token.httpx.post",
|
||||
lambda *args, **kwargs: FakeResponse({"code": 0, "tenant_access_token": "fresh", "expire": 7200}),
|
||||
"review_agent.notifications.feishu_message_api.get_tenant_access_token",
|
||||
lambda force_refresh=False: type(
|
||||
"TokenResult",
|
||||
(),
|
||||
{"ok": True, "tenant_access_token": "fresh", "error_code": "", "error_message": ""},
|
||||
)(),
|
||||
)
|
||||
|
||||
result = send_personal_message(
|
||||
|
||||
Reference in New Issue
Block a user