Files
query-payslip-default/tests/samples/test_golden_cases.py.sample
skill-dev 3db196e49d feat: 工资查询助手首版 v1.0.105
基于 skill-template 脚手架开发,包含:
- payroll_config(费率配置,可编辑)+ payslip_snapshots(解析历史,只读)2 张业务表
- 全国默认 + 北上广 4 套费率(社保/公积金/个税起征点/7 级税率表)
- 5 个业务 Action:calculate-payslip-simple / calculate-payslip-full / explain-term / view-config / edit-config
- 个税累计预扣法计算,支持多月历史累加
- 20 个薪资名词库(社保/公积金/个税/全勤/加班费等)
- 完整市场文档(README/TUTORIAL/DEMO/CHANGELOG)
- 296 测试全部通过
2026-09-07 17:02:05 +08:00

38 lines
1.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
# 样例:复制为 ``tests/test_golden_cases.py`` 后运行;默认不收集。
"""
Golden fixture 回归(示意)。
- 从 ``tests/fixtures/`` 读取脱敏 JSON。
- 调用 service 层(复制后替换为真实 import)。
- 断言关键字段,而非全文 diff(外部系统常带时间戳/非确定性字段)。
"""
from __future__ import annotations
import json
import os
import unittest
def _fixtures_dir() -> str:
return os.path.join(os.path.dirname(__file__), "..", "fixtures")
class TestGoldenCasesSample(unittest.TestCase):
def test_sample_request_matches_expected_shape(self) -> None:
req_path = os.path.join(_fixtures_dir(), "sample_request.json")
exp_path = os.path.join(_fixtures_dir(), "expected_response.json")
with open(req_path, encoding="utf-8") as f:
req = json.load(f)
with open(exp_path, encoding="utf-8") as f:
exp = json.load(f)
self.assertEqual(req["request_id"], "req_test_001")
self.assertTrue(req["parameters"]["options"]["dry_run"])
# 示意:out = run(req); 然后 assert out["success"] == exp["success"] 等关键字段
self.assertTrue(exp["success"])
self.assertEqual(exp["data"]["status"], "ok")
if __name__ == "__main__":
unittest.main()