feat(backend): write storage cert and insurance at sample level in quick-register.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
edabf70287
commit
50400ad19c
6 files changed
+406
-32
No files matched your search
@@ -0,0 +1,90 @@
|
||||
"""样本级储存证 / 保险:handled 判定与 quick-register items 去重。"""
|
||||
from types import SimpleNamespace
|
||||
from datetime import datetime
|
||||
|
||||
from app.services.sample_info_progress import insurance_handled, storage_cert_handled
|
||||
from app.services.sample_info_quick_register import unique_sample_items
|
||||
|
||||
|
||||
def test_storage_cert_handled_true_when_handle_time_set():
|
||||
assert (
|
||||
storage_cert_handled(
|
||||
SimpleNamespace(handle_time=object(), make_status="0", make_date=None)
|
||||
)
|
||||
is True
|
||||
)
|
||||
assert storage_cert_handled(None) is False
|
||||
|
||||
|
||||
def test_storage_cert_handled_legacy_fields():
|
||||
assert (
|
||||
storage_cert_handled(
|
||||
SimpleNamespace(handle_time=None, make_status="1", make_date="")
|
||||
)
|
||||
is True
|
||||
)
|
||||
assert (
|
||||
storage_cert_handled(
|
||||
SimpleNamespace(handle_time=None, make_status="0", make_date="20260101")
|
||||
)
|
||||
is True
|
||||
)
|
||||
assert (
|
||||
storage_cert_handled(
|
||||
SimpleNamespace(handle_time=None, make_status="0", make_date="")
|
||||
)
|
||||
is False
|
||||
)
|
||||
|
||||
|
||||
def test_insurance_handled_true_when_handle_time_set():
|
||||
assert (
|
||||
insurance_handled(
|
||||
SimpleNamespace(
|
||||
handle_time=datetime(2026, 10, 1, 8, 0),
|
||||
todo_status="0",
|
||||
handle_date="",
|
||||
)
|
||||
)
|
||||
is True
|
||||
)
|
||||
assert insurance_handled(None) is False
|
||||
|
||||
|
||||
def test_insurance_handled_legacy_fields():
|
||||
assert (
|
||||
insurance_handled(
|
||||
SimpleNamespace(handle_time=None, todo_status="1", handle_date="")
|
||||
)
|
||||
is True
|
||||
)
|
||||
assert (
|
||||
insurance_handled(
|
||||
SimpleNamespace(handle_time=None, todo_status="0", handle_date="20260131")
|
||||
)
|
||||
is True
|
||||
)
|
||||
assert (
|
||||
insurance_handled(
|
||||
SimpleNamespace(handle_time=None, todo_status="0", handle_date="")
|
||||
)
|
||||
is False
|
||||
)
|
||||
|
||||
|
||||
def test_unique_sample_items_dedupes_by_sample_code():
|
||||
pairs = unique_sample_items(
|
||||
[
|
||||
{"sampleCode": "S1", "protocolId": "P1"},
|
||||
{"sampleCode": " S1 ", "protocolId": "P9"},
|
||||
{"sampleCode": "S2", "protocolId": "P2"},
|
||||
{"sampleCode": "", "protocolId": "P3"},
|
||||
{"sampleCode": "S2", "protocolId": "P2"},
|
||||
]
|
||||
)
|
||||
assert pairs == [("S1", "P1"), ("S2", "P2")]
|
||||
|
||||
|
||||
def test_unique_sample_items_empty():
|
||||
assert unique_sample_items([]) == []
|
||||
assert unique_sample_items(None) == []
|
||||
Reference in new issue
Block a user