Files
zkxw/backend/tests/test_sample_info_quick_register.py
T
zlwuandCursor db31990ebe feat: 细胞存储缴费催缴、统一样本信息与协议支付能力增强
汇总近期业务改动:催缴菜单与后端、样本信息快捷登记与进度、运费关联、客户档案扩展、协议优惠/期次与押金划转,并同步 SQL 迁移与管理端页面收敛。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-10 21:20:37 +08:00

43 lines
1.4 KiB
Python

"""样本信息列表快捷登记:去重与入库字段规范化。"""
import unittest
from datetime import datetime
from app.services.sample_info_quick_register import (
apply_quick_storage_payload,
unique_nonempty_ids,
)
class TestUniqueNonemptyIds(unittest.TestCase):
def test_keeps_order_and_drops_blank_dupes(self):
self.assertEqual(
unique_nonempty_ids([" a ", "b", "a", "", None, "b"]),
["a", "b"],
)
def test_empty(self):
self.assertEqual(unique_nonempty_ids([]), [])
class TestApplyQuickStoragePayload(unittest.TestCase):
def test_requires_handle_time(self):
with self.assertRaises(ValueError):
apply_quick_storage_payload(
handle_time=None, handler_user_id="u1", attachments="", remark=""
)
def test_maps_to_stored_fields(self):
ht = datetime(2026, 10, 6, 10, 30, 0)
out = apply_quick_storage_payload(
handle_time=ht,
handler_user_id="u1",
attachments="http://f.pdf",
remark="ok",
)
self.assertEqual(out["storage_status"], "yrk")
self.assertEqual(out["storage_time"], ht)
self.assertEqual(out["storage_by"], "u1")
self.assertEqual(out["storage_in_date"], "20261006")
self.assertEqual(out["attachments"], "http://f.pdf")
self.assertEqual(out["remark"], "ok")