fix: handle feishu login network errors

maintainer edit: keep QR login network failures on the expected failure path instead of crashing the channels login command.
This commit is contained in:
chengyongru
2026-06-18 22:38:06 +08:00
committed by Xubin Ren
parent a56cd9710b
commit 5dfdd4f892
2 changed files with 13 additions and 1 deletions
+10
View File
@@ -1,5 +1,6 @@
import json
import httpx
import pytest
from nanobot.channels import feishu as feishu_module
@@ -46,6 +47,15 @@ def test_begin_registration_requires_login_url(monkeypatch):
feishu_module._begin_registration()
def test_qr_register_returns_none_on_network_error(monkeypatch):
def raise_connect_error(_base_url, _body):
raise httpx.ConnectError("network down")
monkeypatch.setattr(feishu_module, "_post_registration", raise_connect_error)
assert feishu_module.qr_register() is None
@pytest.mark.asyncio
async def test_feishu_login_creates_missing_active_config(monkeypatch, tmp_path):
missing_config = tmp_path / "missing.json"