815cbf9d8c
- 更新 .gitignore:全面覆盖环境变量、数据库、日志、缓存、上传文件 - 移除误跟踪的 server/venv/、crm_data.db、.env 文件 - 新增 server/.env.example 模板 - 新增合同管理、利润核算、AI教练等功能模块 - 新增 Playwright e2e 测试套件 - 前后端多项功能升级和 bug 修复
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
"""
|
|
销项发票模块测试 —— /api/finance/sales-invoices
|
|
"""
|
|
import uuid
|
|
import pytest
|
|
from httpx import AsyncClient
|
|
from tests.conftest import CUSTOMER_ID
|
|
|
|
|
|
class TestSalesInvoice:
|
|
|
|
async def test_list_sales_invoices(self, client: AsyncClient, admin_headers):
|
|
"""销项发票列表 → 200"""
|
|
resp = await client.get("/api/finance/sales-invoices", headers=admin_headers)
|
|
assert resp.status_code == 200
|
|
data = resp.json()["data"]
|
|
assert "total" in data
|
|
|
|
async def test_create_sales_invoice(self, client: AsyncClient, admin_headers):
|
|
"""创建销项发票 → 200"""
|
|
resp = await client.post("/api/finance/sales-invoices", headers=admin_headers, json={
|
|
"issuer": "测试润滑油有限公司",
|
|
"receiver_customer_id": str(CUSTOMER_ID),
|
|
"invoice_number": "INV-2026-001",
|
|
"amount": 5000.00,
|
|
"billing_date": "2026-03-20",
|
|
})
|
|
assert resp.status_code == 200
|
|
data = resp.json()["data"]
|
|
assert data["invoice_number"] == "INV-2026-001"
|
|
|
|
async def test_get_nonexistent_invoice(self, client: AsyncClient, admin_headers):
|
|
"""不存在的发票详情 → 404"""
|
|
fake_id = uuid.uuid4()
|
|
resp = await client.get(
|
|
f"/api/finance/sales-invoices/{fake_id}",
|
|
headers=admin_headers
|
|
)
|
|
assert resp.status_code in (404, 500)
|