5278190750
- 后端: 凭证生成引擎、金蝶导出器、凭证模板服务 - 后端: 成本分析服务、AI问答服务 - 后端: 科目映射CRUD API、分析API、QA API - 后端: 集成测试(认证/任务/凭证) 49个测试全部通过 - 前端: 凭证管理、成本分析、导出中心、知识库、系统设置页面 - 前端: AuthGuard认证守卫、Dashboard AI聊天功能 - 前端: Playwright E2E测试 16 passed, 1 skipped - 基础设施: Docker Compose、Nginx反向代理、.env.example - 文档: 用户手册、管理员手册、发布检查清单
66 lines
2.6 KiB
Python
66 lines
2.6 KiB
Python
"""
|
|
凭证模板服务单元测试
|
|
|
|
测试 VoucherTemplate 的默认科目映射
|
|
"""
|
|
|
|
import pytest
|
|
|
|
from app.services.voucher.template import VoucherTemplate, DEFAULT_ACCOUNT_TEMPLATES
|
|
|
|
|
|
class TestVoucherTemplate:
|
|
"""凭证模板服务测试"""
|
|
|
|
def test_get_default_template_existing(self):
|
|
"""测试获取已存在的字段模板"""
|
|
template = VoucherTemplate.get_default_template("基本工资")
|
|
assert template is not None
|
|
assert template["debit_account"] == "6601.01"
|
|
assert template["credit_account"] == "2211.01"
|
|
assert "管理费用" in template["debit_account_name"]
|
|
assert "应付职工薪酬" in template["credit_account_name"]
|
|
|
|
def test_get_default_template_nonexistent(self):
|
|
"""测试获取不存在的字段模板"""
|
|
template = VoucherTemplate.get_default_template("不存在的字段")
|
|
assert template == {}
|
|
|
|
def test_get_all_templates(self):
|
|
"""测试获取所有模板"""
|
|
templates = VoucherTemplate.get_all_templates()
|
|
assert len(templates) > 0
|
|
assert "基本工资" in templates
|
|
assert "养老保险(公司)" in templates
|
|
assert "公积金(公司)" in templates
|
|
assert "实发工资" in templates
|
|
|
|
def test_get_template_fields(self):
|
|
"""测试获取模板字段列表"""
|
|
fields = VoucherTemplate.get_template_fields()
|
|
assert len(fields) > 0
|
|
assert "基本工资" in fields
|
|
assert isinstance(fields, list)
|
|
|
|
def test_template_structure(self):
|
|
"""测试模板结构完整性"""
|
|
for field, template in DEFAULT_ACCOUNT_TEMPLATES.items():
|
|
assert "debit_account" in template, f"字段 {field} 缺少 debit_account"
|
|
assert "debit_account_name" in template, f"字段 {field} 缺少 debit_account_name"
|
|
assert "credit_account" in template, f"字段 {field} 缺少 credit_account"
|
|
assert "credit_account_name" in template, f"字段 {field} 缺少 credit_account_name"
|
|
|
|
def test_social_security_templates(self):
|
|
"""测试社保相关模板"""
|
|
for field in ["养老保险(公司)", "医疗保险(公司)", "失业保险(公司)"]:
|
|
template = VoucherTemplate.get_default_template(field)
|
|
assert template != {}
|
|
assert "社保" in template["debit_account_name"]
|
|
|
|
def test_fund_template(self):
|
|
"""测试公积金模板"""
|
|
template = VoucherTemplate.get_default_template("公积金(公司)")
|
|
assert template != {}
|
|
assert "公积金" in template["debit_account_name"]
|
|
assert "公积金" in template["credit_account_name"]
|