Files
AIPortPilot/backend/tests/test_phase2_smoke.py
T
selfrelease fad458b2a7 docs(uiux): UIUX 设计方案大改 + 5 份作业指导书对齐 + 开发任务文档
- UIUX 文档:填充 19 个缺口(多主体画像/健康度/AI+看板/增长域/洞察域/创始人端/OODA/助推/商密)
- UIUX 文档:插入 6 个新章节(十四~十九),旧章节重编号为二十~三十一,更新目录和交叉引用
- 作业指导书 x5:导航改为 6 域分组,新增 Context Bar/工作模式/Insight Rail/决策线程/多工作区等 UI 概念
- 新建 docs/2-task-uiux.md:50 个代码落地开发任务,按 P0-P6 分优先级 + 8 Sprint 规划
- 后端/前端:大量新增模型、路由、组件(来自之前 Phase 开发)
2026-07-19 11:53:38 +08:00

159 lines
5.8 KiB
Python

"""Phase 2 路由冒烟测试 — 财务/协议/董事会/弱信号/决策前哨/重大事项。"""
import pytest
from fastapi.testclient import TestClient
class TestFinancialRouter:
"""财务数据路由冒烟测试。"""
def test_list_financial_empty(self, client: TestClient, auth_headers: dict, company_id: str):
"""GET /financial?company_id=xxx 空列表应返回 200。"""
resp = client.get(f"/api/v1/financial?company_id={company_id}", headers=auth_headers)
assert resp.status_code == 200
assert resp.json()["code"] == 0
def test_create_financial(self, client: TestClient, auth_headers: dict, company_id: str):
"""POST /financial 创建财务数据应返回 201。"""
resp = client.post(
"/api/v1/financial",
json={
"company_id": company_id,
"period_year": 2025,
"period_month": 6,
"revenue": 1000000,
"expenses": 800000,
},
headers=auth_headers,
)
assert resp.status_code == 201
assert resp.json()["code"] == 0
assert "id" in resp.json()["data"]
def test_list_financial_after_create(self, client: TestClient, auth_headers: dict, company_id: str):
"""先创建再查询,应能查到数据。"""
client.post(
"/api/v1/financial",
json={
"company_id": company_id,
"period_year": 2025,
"period_month": 7,
"revenue": 1200000,
"expenses": 900000,
},
headers=auth_headers,
)
resp = client.get(f"/api/v1/financial?company_id={company_id}", headers=auth_headers)
assert resp.status_code == 200
data = resp.json()["data"]
assert len(data) >= 1
def test_financial_without_auth(self, client: TestClient, company_id: str):
"""无认证应返回 401/403。"""
resp = client.get(f"/api/v1/financial?company_id={company_id}")
assert resp.status_code in (401, 403)
class TestAgreementRouter:
"""投资协议路由冒烟测试。"""
def test_list_agreements_empty(self, client: TestClient, auth_headers: dict):
"""GET /agreements 空列表应返回 200。"""
resp = client.get("/api/v1/agreements", headers=auth_headers)
assert resp.status_code == 200
assert resp.json()["code"] == 0
def test_create_agreement(self, client: TestClient, auth_headers: dict, company_id: str):
"""POST /agreements 创建协议应返回 201。"""
resp = client.post(
"/api/v1/agreements",
json={
"company_id": company_id,
"title": "A轮投资协议",
"signed_date": "2025-01-15",
"investment_amount": 5000000,
},
headers=auth_headers,
)
assert resp.status_code == 201
assert resp.json()["code"] == 0
def test_agreement_without_auth(self, client: TestClient):
"""无认证应返回 401/403。"""
resp = client.get("/api/v1/agreements")
assert resp.status_code in (401, 403)
class TestBoardRouter:
"""董事会路由冒烟测试。"""
def test_list_board_meetings_empty(self, client: TestClient, auth_headers: dict):
"""GET /board 空列表应返回 200。"""
resp = client.get("/api/v1/board", headers=auth_headers)
assert resp.status_code == 200
assert resp.json()["code"] == 0
def test_create_board_meeting(self, client: TestClient, auth_headers: dict, company_id: str):
"""POST /board 创建会议应返回 201。"""
resp = client.post(
"/api/v1/board",
json={
"company_id": company_id,
"title": "2025年Q3董事会",
"meeting_date": "2025-07-20",
},
headers=auth_headers,
)
assert resp.status_code == 201
assert resp.json()["code"] == 0
def test_board_without_auth(self, client: TestClient):
"""无认证应返回 401/403。"""
resp = client.get("/api/v1/board")
assert resp.status_code in (401, 403)
class TestWeakSignalRouter:
"""弱信号路由冒烟测试。"""
def test_list_weak_signals_empty(self, client: TestClient, auth_headers: dict):
"""GET /weak-signals 空列表应返回 200。"""
resp = client.get("/api/v1/weak-signals", headers=auth_headers)
assert resp.status_code == 200
assert resp.json()["code"] == 0
def test_weak_signals_without_auth(self, client: TestClient):
"""无认证应返回 401/403。"""
resp = client.get("/api/v1/weak-signals")
assert resp.status_code in (401, 403)
class TestDecisionSentinelRouter:
"""决策前哨路由冒烟测试。"""
def test_list_sentinels_empty(self, client: TestClient, auth_headers: dict):
"""GET /decision-sentinels 空列表应返回 200。"""
resp = client.get("/api/v1/decision-sentinels", headers=auth_headers)
assert resp.status_code == 200
assert resp.json()["code"] == 0
def test_sentinels_without_auth(self, client: TestClient):
"""无认证应返回 401/403。"""
resp = client.get("/api/v1/decision-sentinels")
assert resp.status_code in (401, 403)
class TestEventRouter:
"""重大事项路由冒烟测试。"""
def test_list_events_empty(self, client: TestClient, auth_headers: dict):
"""GET /events 空列表应返回 200。"""
resp = client.get("/api/v1/events", headers=auth_headers)
assert resp.status_code == 200
assert resp.json()["code"] == 0
def test_events_without_auth(self, client: TestClient):
"""无认证应返回 401/403。"""
resp = client.get("/api/v1/events")
assert resp.status_code in (401, 403)