feat(pl): collect hazard certs for archive zip export.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d68a0ef0bd
commit
7af4d7ac7e
2 files changed
+99
-1
No files matched your search
@@ -3,6 +3,9 @@ from app.services.pl_plan_archive_zip_export import (
|
||||
build_attachment_filename,
|
||||
first_row_no_by_plan_id,
|
||||
build_hyperlink_formula,
|
||||
parse_url_list,
|
||||
collect_hazard_cert_items,
|
||||
merge_plan_attachment_items,
|
||||
)
|
||||
|
||||
|
||||
@@ -30,3 +33,30 @@ def test_build_hyperlink_formula():
|
||||
f = build_hyperlink_formula("附件/01_司机_ab12.jpg", "司机")
|
||||
assert f.startswith('=HYPERLINK(')
|
||||
assert "附件/01_司机_ab12.jpg" in f
|
||||
|
||||
|
||||
def test_parse_url_list_csv_and_json():
|
||||
assert parse_url_list("a.jpg,b.jpg") == ["a.jpg", "b.jpg"]
|
||||
assert parse_url_list('["x.png","y.png"]') == ["x.png", "y.png"]
|
||||
|
||||
|
||||
def test_collect_hazard_cert_items_labels():
|
||||
class P:
|
||||
product_name = "甲醇"
|
||||
purchase_cert_url = "https://x/p.pdf"
|
||||
transport_cert_url = None
|
||||
legal_use_cert_url = "https://x/l1.pdf,https://x/l2.pdf"
|
||||
|
||||
items = collect_hazard_cert_items([P()])
|
||||
labels = [i["label"] for i in items]
|
||||
assert "购买证" in labels[0]
|
||||
assert any("合法使用证明" in x for x in labels)
|
||||
assert len(items) == 3
|
||||
|
||||
|
||||
def test_merge_dedupes_url():
|
||||
doc = [{"url": "https://a/1.jpg", "label": "司机"}]
|
||||
haz = [{"url": "https://a/1.jpg", "label": "购买证"}]
|
||||
merged = merge_plan_attachment_items(doc, haz)
|
||||
assert len(merged) == 1
|
||||
assert merged[0]["label"] == "司机"
|
||||
Reference in new issue
Block a user