43 lines
1.8 KiB
Python
43 lines
1.8 KiB
Python
"""权限版本详情应使用中文化、可视化展示。"""
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
AUTH = (ROOT / 'routes' / 'auth.py').read_text(encoding='utf-8')
|
|
APP = (ROOT / 'static' / 'js' / 'app.js').read_text(encoding='utf-8')
|
|
CSS = (ROOT / 'static' / 'css' / 'style.css').read_text(encoding='utf-8')
|
|
|
|
|
|
class PermissionVersionVisualizationTest(unittest.TestCase):
|
|
def test_version_detail_api_returns_creator_name(self):
|
|
self.assertIn('u.real_name AS creator_name', AUTH)
|
|
self.assertIn("row['created_at'].strftime('%Y-%m-%d %H:%M:%S')", AUTH)
|
|
|
|
def test_raw_json_detail_is_replaced_by_chinese_sections(self):
|
|
self.assertIn('页面与操作权限', APP)
|
|
self.assertIn('字段权限', APP)
|
|
self.assertIn('数据范围', APP)
|
|
self.assertIn('允许的操作', APP)
|
|
self.assertIn('禁止的操作', APP)
|
|
self.assertNotIn("text=JSON.stringify(res.data.snapshot||{},null,2)", APP)
|
|
|
|
def test_page_operation_scope_translations_exist(self):
|
|
self.assertIn('_permissionVersionPageInfo', APP)
|
|
self.assertIn('_permissionVersionOperationName', APP)
|
|
self.assertIn("all:'全部数据'", APP)
|
|
self.assertIn("planner:'所属采购计划'", APP)
|
|
|
|
def test_visual_status_and_summary_styles_exist(self):
|
|
for name in ('perm-version-summary-grid', 'perm-version-stat', 'perm-status-badge', 'perm-version-page-block'):
|
|
self.assertIn(name, APP)
|
|
self.assertIn('.' + name, CSS)
|
|
|
|
def test_version_compare_is_chinese_visualized(self):
|
|
self.assertIn('_permissionVersionChangeLabel', APP)
|
|
self.assertIn('权限版本差异', APP)
|
|
self.assertIn('权限项目', APP)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|