fix: 设备验收预警优化
This commit is contained in:
1 parent
7e7bcbd388
commit
b8cc0cbe77
25 files changed
+1398
-193
No files matched your search
@@ -0,0 +1,58 @@
|
||||
"""
|
||||
tests/test_equipment_acceptance_alert_notice.py
|
||||
|
||||
用途:锁定设备验收企微汇总文案和 Excel 列。
|
||||
依赖:alert_notice、openpyxl。
|
||||
逻辑:不连数据库,不发企业微信。卡片只写张数。工作簿含申请人,不写主送。
|
||||
"""
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
import pytest
|
||||
from openpyxl import load_workbook
|
||||
|
||||
pytestmark = pytest.mark.pure_unit
|
||||
|
||||
from app.services.equipment_acceptance.alert_notice import (
|
||||
NOTICE_HEADERS,
|
||||
build_notice_workbook,
|
||||
summary_message,
|
||||
)
|
||||
|
||||
|
||||
def test_summary_counts_rounds_without_listing_orders():
|
||||
"""第一行写已逾期张数。正文不出现验收单号,也不写主送。"""
|
||||
text = summary_message([
|
||||
{"threshold_days": 30},
|
||||
{"threshold_days": 30},
|
||||
{"threshold_days": 37},
|
||||
])
|
||||
assert text == "共 3 张验收单已逾期。\n超过 30 天 2 张,超过 37 天 1 张。\n明细见下一条文件。"
|
||||
assert "主送" not in text
|
||||
assert "20260210" not in text
|
||||
|
||||
|
||||
def test_workbook_includes_applicant_and_identity():
|
||||
"""Excel 列与原型一致。通知身份保留角色名,停留天数为空时写横线。"""
|
||||
data = build_notice_workbook([{
|
||||
"acceptance_no": "20260210000001",
|
||||
"purchase_order_no": "1111",
|
||||
"applicant": "孙浩",
|
||||
"threshold_days": 30,
|
||||
"dwell_days": None,
|
||||
"node_name": "使用部门担当",
|
||||
"handlers": "吴敏",
|
||||
"identity": "直接主管",
|
||||
}])
|
||||
sheet = load_workbook(BytesIO(data)).active
|
||||
assert [cell.value for cell in sheet[1]] == list(NOTICE_HEADERS)
|
||||
assert [cell.value for cell in sheet[2]] == [
|
||||
"20260210000001",
|
||||
"1111",
|
||||
"孙浩",
|
||||
"超过 30 天",
|
||||
"—",
|
||||
"使用部门担当",
|
||||
"吴敏",
|
||||
"直接主管",
|
||||
]
|
||||
Reference in new issue
Block a user