feat(training): 培训模块改造!
This commit is contained in:
1 parent
57652ae581
commit
5f713f2c0c
11 files changed
+226
-51
No files matched your search
@@ -655,7 +655,50 @@ def test_non_training_preview_url_keeps_existing_http_fetch_path(monkeypatch):
|
||||
assert content_type == "application/pdf"
|
||||
assert error is None
|
||||
|
||||
def test_training_admin_permission_can_be_granted_by_feature_permission(client, app):
|
||||
def test_dynamic_training_type_code_title_cleanup_and_published_type_list(client, app):
|
||||
"""自定义类型编码应动态可用,资料标题去除首尾空白,列表仅返回已发布类型。"""
|
||||
with app.app_context():
|
||||
admin = _create_user(username="training_type_admin", role="admin")
|
||||
draft = training_config_service.create_config(
|
||||
{
|
||||
"training_type": "compliance_training",
|
||||
"name": "合规培训",
|
||||
"version": "v1.0",
|
||||
"status": "draft",
|
||||
"resources": [],
|
||||
},
|
||||
user_id=admin.id,
|
||||
)
|
||||
published = training_config_service.create_config(
|
||||
{
|
||||
"training_type": "quality-training",
|
||||
"name": "质量培训",
|
||||
"version": "v1.0",
|
||||
"status": "published",
|
||||
"resources": [
|
||||
{
|
||||
"resource_type": "inline_questions",
|
||||
"title": " 质量考试 ",
|
||||
"inline_questions": [{"id": "q1"}],
|
||||
},
|
||||
],
|
||||
},
|
||||
user_id=admin.id,
|
||||
)
|
||||
|
||||
# 关键断言:类型编码被规范化,标题不保留录入空白。
|
||||
assert draft["training_type"] == "compliance_training"
|
||||
assert published["training_type"] == "quality_training"
|
||||
assert published["resources"][0]["title"] == "质量考试"
|
||||
|
||||
headers = _auth_headers(admin)
|
||||
response = client.get("/api/user/training-types", headers=headers)
|
||||
|
||||
# 关键断言:发布类型列表可供前端动态选择,草稿不得暴露。
|
||||
assert response.status_code == 200
|
||||
assert response.get_json() == [{"code": "quality_training", "name": "质量培训"}]
|
||||
|
||||
|
||||
"""培训 HR 管理能力应支持通过功能权限显式授予普通用户。"""
|
||||
with app.app_context():
|
||||
granted_user = _create_user(
|
||||
|
||||
Reference in new issue
Block a user