fad458b2a7
- UIUX 文档:填充 19 个缺口(多主体画像/健康度/AI+看板/增长域/洞察域/创始人端/OODA/助推/商密) - UIUX 文档:插入 6 个新章节(十四~十九),旧章节重编号为二十~三十一,更新目录和交叉引用 - 作业指导书 x5:导航改为 6 域分组,新增 Context Bar/工作模式/Insight Rail/决策线程/多工作区等 UI 概念 - 新建 docs/2-task-uiux.md:50 个代码落地开发任务,按 P0-P6 分优先级 + 8 Sprint 规划 - 后端/前端:大量新增模型、路由、组件(来自之前 Phase 开发)
131 lines
4.7 KiB
Python
131 lines
4.7 KiB
Python
"""Phase 3 路由冒烟测试 — 协同/创新/人才/OKR/里程碑/任务。"""
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
class TestSynergyRouter:
|
|
"""协同机会路由冒烟测试。"""
|
|
|
|
def test_list_synergies_empty(self, client: TestClient, auth_headers: dict):
|
|
"""GET /synergies 空列表应返回 200。"""
|
|
resp = client.get("/api/v1/synergies", headers=auth_headers)
|
|
assert resp.status_code == 200
|
|
assert resp.json()["code"] == 0
|
|
|
|
def test_synergies_without_auth(self, client: TestClient):
|
|
"""无认证应返回 401/403。"""
|
|
resp = client.get("/api/v1/synergies")
|
|
assert resp.status_code in (401, 403)
|
|
|
|
|
|
class TestInnovationRouter:
|
|
"""组合创新路由冒烟测试。"""
|
|
|
|
def test_discover_innovation(self, client: TestClient, auth_headers: dict):
|
|
"""POST /innovation/discover 应返回 200。"""
|
|
resp = client.post(
|
|
"/api/v1/innovation/discover",
|
|
json={"portfolio_capabilities": "AI模型训练, 数据标注, 云计算"},
|
|
headers=auth_headers,
|
|
)
|
|
assert resp.status_code == 200
|
|
assert resp.json()["code"] == 0
|
|
|
|
def test_innovation_without_auth(self, client: TestClient):
|
|
"""无认证应返回 401/403。"""
|
|
resp = client.post(
|
|
"/api/v1/innovation/discover",
|
|
json={"portfolio_capabilities": "test"},
|
|
)
|
|
assert resp.status_code in (401, 403)
|
|
|
|
|
|
class TestTalentRouter:
|
|
"""人才引力场路由冒烟测试。"""
|
|
|
|
def test_list_talents_empty(self, client: TestClient, auth_headers: dict):
|
|
"""GET /talents 空列表应返回 200。"""
|
|
resp = client.get("/api/v1/talents", headers=auth_headers)
|
|
assert resp.status_code == 200
|
|
assert resp.json()["code"] == 0
|
|
|
|
def test_talents_without_auth(self, client: TestClient):
|
|
"""无认证应返回 401/403。"""
|
|
resp = client.get("/api/v1/talents")
|
|
assert resp.status_code in (401, 403)
|
|
|
|
|
|
class TestOKRRouter:
|
|
"""OKR 路由冒烟测试。"""
|
|
|
|
def test_list_okrs_empty(self, client: TestClient, auth_headers: dict):
|
|
"""GET /okrs 空列表应返回 200。"""
|
|
resp = client.get("/api/v1/okrs", headers=auth_headers)
|
|
assert resp.status_code == 200
|
|
assert resp.json()["code"] == 0
|
|
|
|
def test_create_okr(self, client: TestClient, auth_headers: dict, company_id: str):
|
|
"""POST /okrs 创建 OKR 应返回 201。"""
|
|
resp = client.post(
|
|
"/api/v1/okrs",
|
|
json={
|
|
"company_id": company_id,
|
|
"quarter": "2025-Q3",
|
|
"objective": "实现产品商业化",
|
|
"key_results": [{"kr": "签约 10 家客户", "target": 10}],
|
|
},
|
|
headers=auth_headers,
|
|
)
|
|
assert resp.status_code == 201
|
|
assert resp.json()["code"] == 0
|
|
|
|
def test_okrs_without_auth(self, client: TestClient):
|
|
"""无认证应返回 401/403。"""
|
|
resp = client.get("/api/v1/okrs")
|
|
assert resp.status_code in (401, 403)
|
|
|
|
|
|
class TestMilestoneRouter:
|
|
"""里程碑路由冒烟测试。"""
|
|
|
|
def test_list_milestones_empty(self, client: TestClient, auth_headers: dict, company_id: str):
|
|
"""GET /milestones?company_id=xxx 空列表应返回 200。"""
|
|
resp = client.get(f"/api/v1/milestones?company_id={company_id}", headers=auth_headers)
|
|
assert resp.status_code == 200
|
|
assert resp.json()["code"] == 0
|
|
|
|
def test_milestones_without_auth(self, client: TestClient, company_id: str):
|
|
"""无认证应返回 401/403。"""
|
|
resp = client.get(f"/api/v1/milestones?company_id={company_id}")
|
|
assert resp.status_code in (401, 403)
|
|
|
|
|
|
class TestTaskRouter:
|
|
"""任务管理路由冒烟测试。"""
|
|
|
|
def test_list_tasks_empty(self, client: TestClient, auth_headers: dict):
|
|
"""GET /tasks 空列表应返回 200。"""
|
|
resp = client.get("/api/v1/tasks", headers=auth_headers)
|
|
assert resp.status_code == 200
|
|
assert resp.json()["code"] == 0
|
|
|
|
def test_create_task(self, client: TestClient, auth_headers: dict, company_id: str):
|
|
"""POST /tasks 创建任务应返回 201。"""
|
|
resp = client.post(
|
|
"/api/v1/tasks",
|
|
json={
|
|
"company_id": company_id,
|
|
"title": "跟进融资进度",
|
|
"assignee": "投资经理A",
|
|
},
|
|
headers=auth_headers,
|
|
)
|
|
assert resp.status_code == 201
|
|
assert resp.json()["code"] == 0
|
|
|
|
def test_tasks_without_auth(self, client: TestClient):
|
|
"""无认证应返回 401/403。"""
|
|
resp = client.get("/api/v1/tasks")
|
|
assert resp.status_code in (401, 403)
|