"""T3.4 客户增长引擎测试。""" import pytest from fastapi.testclient import TestClient class TestCustomerPlansList: """客户获取方案列表接口测试。""" def test_list_plans_empty(self, client: TestClient, auth_headers: dict): """无方案时应返回空列表。""" resp = client.get("/api/v1/customer-plans", headers=auth_headers) assert resp.status_code == 200 assert resp.json()["code"] == 0 assert isinstance(resp.json()["data"], list) def test_list_plans_with_company_filter(self, client: TestClient, auth_headers: dict, company_id: str): """指定企业 ID 过滤方案列表。""" resp = client.get(f"/api/v1/customer-plans?company_id={company_id}", headers=auth_headers) assert resp.status_code == 200 assert isinstance(resp.json()["data"], list) def test_list_plans_no_auth(self, client: TestClient): """未认证应返回 401。""" resp = client.get("/api/v1/customer-plans") assert resp.status_code == 401 class TestCustomerPlanGenerate: """AI 生成客户获取方案接口测试。""" def test_generate_plan_success(self, client: TestClient, auth_headers: dict): """AI 生成客户获取方案。""" resp = client.post( "/api/v1/customer-plans/generate", json={ "company_context": "AI 教育公司,面向 K12 市场", "lp_resources": "LP 拥有教育行业资源,包括学校关系和教育部门人脉", }, headers=auth_headers, ) assert resp.status_code == 200 data = resp.json()["data"] assert isinstance(data, dict) def test_generate_plan_no_auth(self, client: TestClient): """未认证应返回 401。""" resp = client.post("/api/v1/customer-plans/generate", json={}) assert resp.status_code == 401 def test_generate_plan_empty_body(self, client: TestClient, auth_headers: dict): """空请求体应正常返回(AI 返回 mock 数据)。""" resp = client.post( "/api/v1/customer-plans/generate", json={"company_context": "", "lp_resources": ""}, headers=auth_headers, ) assert resp.status_code == 200