"""技术型操作日志中文化展示。""" import unittest from pathlib import Path from flask import Flask from services.audit import _is_read_only_request ROOT=Path(__file__).resolve().parents[1] APP=(ROOT/'static/js/app.js').read_text(encoding='utf-8') AUDIT=(ROOT/'services/audit.py').read_text(encoding='utf-8') SCHEMA=(ROOT/'services/audit_schema.py').read_text(encoding='utf-8') class T(unittest.TestCase): def test_read_only_post_lists_are_excluded(self): app=Flask(__name__) with app.test_request_context('/api/finished/list',method='POST'):self.assertTrue(_is_read_only_request()) with app.test_request_context('/api/domestic/orders/update',method='POST'):self.assertFalse(_is_read_only_request()) def test_business_action_mapping_exists(self): self.assertIn("('/api/domestic/orders/update','编辑国内订单')",SCHEMA) self.assertIn("('/api/purchase/confirm_order','确认下单')",SCHEMA) def test_frontend_humanizes_history_and_keeps_raw_details(self): self.assertIn('humanizeLogContent',APP);self.assertIn('查询成品提货列表',APP);self.assertIn('查看原始技术信息',APP);self.assertIn('筛选条件:无',APP) if __name__=='__main__':unittest.main()