26 lines
977 B
Python
26 lines
977 B
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')
|
|
|
|
|
|
class PermissionPositionLabelsTest(unittest.TestCase):
|
|
def test_permissions_user_api_joins_position_master(self):
|
|
self.assertIn('LEFT JOIN user_positions p ON BINARY p.position_code=BINARY u.position', AUTH)
|
|
self.assertIn('AS position_name', AUTH)
|
|
|
|
def test_dropdown_and_cards_use_position_name(self):
|
|
self.assertIn('posMap[u.position] = u.position_name', APP)
|
|
self.assertIn('position.name', APP)
|
|
self.assertIn("var posName = u.position_name", APP)
|
|
|
|
def test_unknown_code_is_not_exposed_to_users(self):
|
|
self.assertIn("u.position ? '其他岗位' : '未设置岗位'", APP)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|