37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import pytest
|
|
from httpx import AsyncClient
|
|
|
|
|
|
class TestLeadsAPI:
|
|
async def test_create_private_lead(self, client: AsyncClient):
|
|
res = await client.post(
|
|
"/api/v1/leads",
|
|
json={
|
|
"type": "private",
|
|
"name": "张三",
|
|
"company": "测试外贸公司",
|
|
"phone": "13800138000",
|
|
"message": "想私有化部署",
|
|
},
|
|
)
|
|
assert res.status_code == 200
|
|
data = res.json()
|
|
assert data["type"] == "private"
|
|
assert data["status"] == "new"
|
|
assert data["id"]
|
|
|
|
async def test_create_buyout_lead(self, client: AsyncClient):
|
|
res = await client.post(
|
|
"/api/v1/leads",
|
|
json={"type": "buyout", "name": "李四", "phone": "13900139000"},
|
|
)
|
|
assert res.status_code == 200
|
|
assert res.json()["type"] == "buyout"
|
|
|
|
async def test_invalid_type_rejected(self, client: AsyncClient):
|
|
res = await client.post(
|
|
"/api/v1/leads",
|
|
json={"type": "wrong", "name": "x", "phone": "1"},
|
|
)
|
|
assert res.status_code == 400
|