ForcePilot/test/api/test_dashboard_router.py
Wenjie Zhang c72e2cfb90 test: 增加路由的集成测试
- 新增多个集成测试,涵盖认证、聊天、知识库和系统路由的API端点
- 更新测试环境变量配置,确保测试凭据的灵活性
- 移除冗余的测试文件,优化测试结构
2025-10-11 01:07:45 +08:00

26 lines
825 B
Python

"""
Integration tests for dashboard router endpoints.
"""
from __future__ import annotations
import pytest
pytestmark = [pytest.mark.asyncio, pytest.mark.integration]
async def test_dashboard_requires_authentication(test_client):
response = await test_client.get("/api/dashboard/conversations")
assert response.status_code == 401
async def test_standard_user_is_forbidden(test_client, standard_user):
response = await test_client.get("/api/dashboard/conversations", headers=standard_user["headers"])
assert response.status_code == 403
async def test_admin_can_fetch_conversations(test_client, admin_headers):
response = await test_client.get("/api/dashboard/conversations", headers=admin_headers)
assert response.status_code == 200, response.text
assert isinstance(response.json(), list)