fix: 设备验收预警优化
This commit is contained in:
1 parent
7e7bcbd388
commit
b8cc0cbe77
25 files changed
+1398
-193
No files matched your search
@@ -1,15 +1,15 @@
|
||||
"""
|
||||
tests/test_equipment_acceptance_config.py
|
||||
|
||||
用途:锁定设备验收预警四档天数的保存前校验。
|
||||
依赖:config_service.validate_reminder_days、ValidationError。
|
||||
逻辑:不连数据库。默认 30/37/44/51 通过;相等、倒序、非整数和空岗位以外的天数形状被拒绝。
|
||||
用途:锁定设备验收预警四档天数和第 4 轮开关的保存前校验。
|
||||
依赖:config_service.validate_reminder_days、parse_round_4_enabled、ValidationError。
|
||||
逻辑:不连数据库。默认 30/37/44/51 通过;相等、倒序、非整数和空岗位以外的天数形状被拒绝。第 4 轮缺省关闭。
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from app.core.errors import ValidationError
|
||||
from app.services.equipment_acceptance.config_service import validate_reminder_days
|
||||
from app.services.equipment_acceptance.config_service import parse_round_4_enabled, validate_reminder_days
|
||||
|
||||
|
||||
def test_default_reminder_days_pass():
|
||||
@@ -30,3 +30,13 @@ def test_days_reject_bool_and_wrong_length():
|
||||
validate_reminder_days([True, 37, 44, 51])
|
||||
with pytest.raises(ValidationError):
|
||||
validate_reminder_days([30, 37, 44])
|
||||
|
||||
|
||||
def test_round_4_defaults_off_and_rejects_non_bool():
|
||||
"""未传开关时按关闭处理。数字 1 不能当成启用,避免误通知总经理。"""
|
||||
assert parse_round_4_enabled(None) is False
|
||||
assert parse_round_4_enabled(False) is False
|
||||
assert parse_round_4_enabled(True) is True
|
||||
with pytest.raises(ValidationError) as caught:
|
||||
parse_round_4_enabled(1)
|
||||
assert caught.value.code == "EQUIPMENT_ACCEPTANCE.SETTINGS_INVALID"
|
||||
Reference in new issue
Block a user