fix feishu reauth for online docs

This commit is contained in:
wuyang6
2026-07-02 14:02:01 +08:00
parent 0007d99763
commit 8eadc25b19
5 changed files with 243 additions and 13 deletions
+28
View File
@@ -109,6 +109,34 @@ class FeishuIntegrationTests(unittest.TestCase):
)
self.assertEqual(online_docs['files'][str(file_path)]['kind'], 'doc')
def test_create_online_doc_returns_login_required_when_mcp_token_expired(self) -> None:
with tempfile.TemporaryDirectory() as tmp_dir:
client, state = _build_client(Path(tmp_dir))
file_path = _write_account_file(state, 'alice', 'draft.md', '# hello')
with patch.object(
gui_server,
'_feishu_status_payload',
return_value={'logged_in': True, 'status': 'logged_in'},
), patch.object(
gui_server.MCPRuntime,
'call_tool',
side_effect=RuntimeError('登录已过期或未登录,请重新授权'),
), patch.object(
gui_server,
'_run_feishu_cli',
return_value={'returncode': 0, 'output': 'logged out'},
):
response = client.post(
'/api/files/online-doc',
json={'account_id': 'alice', 'path': str(file_path)},
)
self.assertEqual(response.status_code, 409)
detail = response.json()['detail']
self.assertEqual(detail['code'], 'feishu_auth_expired')
self.assertTrue(detail['force_login'])
def test_create_online_doc_converts_csv_to_feishu_sheet(self) -> None:
with tempfile.TemporaryDirectory() as tmp_dir:
client, state = _build_client(Path(tmp_dir))