feat(training): 出国规则培训完成推送企微通知!
This commit is contained in:
1 parent
258098ea7b
commit
77851288f7
8 files changed
+60
-5
No files matched your search
@@ -268,6 +268,43 @@ def test_overseas_regulations_video_completion_creates_passed_result(client, app
|
||||
assert isinstance(body["completion_time"], str) and body["completion_time"]
|
||||
|
||||
|
||||
def test_overseas_regulations_video_completion_sends_wecom_notice_each_time(client, app, monkeypatch):
|
||||
"""关键断言:每次出国规章视频完成都必须生成一次泰国出差准则企微通知,不能按历史完成记录去重。"""
|
||||
sent_messages = []
|
||||
monkeypatch.setattr(
|
||||
training_service,
|
||||
"send_wecom_event_message",
|
||||
lambda **kwargs: sent_messages.append(kwargs) or {"ok": True, "trace_id": "training-notice-trace"},
|
||||
)
|
||||
with app.app_context():
|
||||
user = _create_user(username="overseas_wecom_notice")
|
||||
db.session.add(TrainingConfig(
|
||||
training_type="overseas_notice_v1",
|
||||
name="出国规章培训",
|
||||
version="v1",
|
||||
status="published",
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
payload = {
|
||||
"type": "overseas_notice_v1",
|
||||
"stage": "result",
|
||||
"score": 100,
|
||||
"passed": True,
|
||||
"attempt_count": 0,
|
||||
"answer_details": [],
|
||||
}
|
||||
first_response = client.put("/api/user/training-record/progress", headers=_auth_headers(user), json=payload)
|
||||
second_response = client.put("/api/user/training-record/progress", headers=_auth_headers(user), json=payload)
|
||||
|
||||
assert first_response.status_code == 200
|
||||
assert second_response.status_code == 200
|
||||
assert len(sent_messages) == 2
|
||||
assert all(message["event_type"] == "training_overseas_thailand_guidelines" for message in sent_messages)
|
||||
assert all(message["title"] == "中国员工出差泰国的行为准则" for message in sent_messages)
|
||||
assert all(message["content"] == "中国员工出差泰国的行为准则" for message in sent_messages)
|
||||
|
||||
|
||||
def test_safety_training_progress_round_trip(client, app):
|
||||
"""安全培训应持久化培训版本、考试模式、三级状态和级别进度。"""
|
||||
with app.app_context():
|
||||
|
||||
Reference in new issue
Block a user