v0.2.0: CRM/ERP 系统升级 - 清理 .gitignore 并移除误提交的 venv/env/db 文件
- 更新 .gitignore:全面覆盖环境变量、数据库、日志、缓存、上传文件 - 移除误跟踪的 server/venv/、crm_data.db、.env 文件 - 新增 server/.env.example 模板 - 新增合同管理、利润核算、AI教练等功能模块 - 新增 Playwright e2e 测试套件 - 前后端多项功能升级和 bug 修复
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"""
|
||||
财务票据模块测试 —— /api/finance
|
||||
覆盖: 票据入池 / 列表 / 作废 / 报销单 CRUD / 审批
|
||||
"""
|
||||
import uuid
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
from tests.conftest import ADMIN_USER_ID, COMPANY_ID
|
||||
|
||||
|
||||
class TestInvoicePool:
|
||||
"""票据池 CRUD"""
|
||||
|
||||
async def test_create_invoice(self, client: AsyncClient, admin_headers):
|
||||
"""票据入池 → 200"""
|
||||
resp = await client.post("/api/finance/invoices", headers=admin_headers, json={
|
||||
"merchant_name": "加油站发票",
|
||||
"amount": 500.00,
|
||||
"invoice_date": "2026-03-15",
|
||||
"type": "expense",
|
||||
"ai_extracted_data": {"invoice_code": "12345678"},
|
||||
})
|
||||
assert resp.status_code == 200
|
||||
|
||||
async def test_list_invoices(self, client: AsyncClient, admin_headers):
|
||||
"""票据列表 → 200"""
|
||||
resp = await client.get("/api/finance/invoices", headers=admin_headers)
|
||||
assert resp.status_code == 200
|
||||
data = resp.json()["data"]
|
||||
assert "total" in data
|
||||
|
||||
async def test_void_nonexistent_invoice(self, client: AsyncClient, admin_headers):
|
||||
"""作废不存在的票据 → 404"""
|
||||
fake_id = uuid.uuid4()
|
||||
resp = await client.delete(f"/api/finance/invoices/{fake_id}", headers=admin_headers)
|
||||
assert resp.status_code in (404, 500)
|
||||
|
||||
|
||||
class TestExpenses:
|
||||
"""报销单"""
|
||||
|
||||
async def test_list_expenses(self, client: AsyncClient, admin_headers):
|
||||
"""报销单列表 → 200"""
|
||||
resp = await client.get("/api/finance/expenses", headers=admin_headers)
|
||||
assert resp.status_code == 200
|
||||
|
||||
async def test_get_nonexistent_expense(self, client: AsyncClient, admin_headers):
|
||||
"""不存在的报销单 → 404"""
|
||||
fake_id = uuid.uuid4()
|
||||
resp = await client.get(f"/api/finance/expenses/{fake_id}", headers=admin_headers)
|
||||
assert resp.status_code in (404, 500)
|
||||
Reference in New Issue
Block a user