""" 销项发票模块测试 —— /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)