"""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)