feat(pl): add archive zip naming helpers and planId on export rows.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-09-23 12:40:04 +08:00
1 parent 1c3c0d40b6
commit e9ffa5d042
3 files changed
+91

No files matched your search

@@ -0,0 +1,33 @@
from app.services.pl_plan_archive_zip_export import (
sanitize_zip_segment,
short_hash,
build_attachment_filename,
first_row_no_by_plan_id,
build_hyperlink_formula,
)
def test_sanitize_zip_segment():
assert sanitize_zip_segment("装货·司机/A") == "装货·司机_A"
assert sanitize_zip_segment(" a ") == "a"
def test_build_attachment_filename():
name = build_attachment_filename(1, "装货·司机", "https://cdn.example/path/a.jpg")
assert name.startswith("01_装货·司机_")
assert name.endswith(".jpg")
def test_first_row_no_by_plan_id():
rows = [
{"planId": "p1", "rowNo": 1},
{"planId": "p1", "rowNo": 2},
{"planId": "p2", "rowNo": 3},
]
assert first_row_no_by_plan_id(rows) == {"p1": 1, "p2": 3}
def test_build_hyperlink_formula():
f = build_hyperlink_formula("附件/01_司机_ab12.jpg", "司机")
assert f.startswith('=HYPERLINK(')
assert "附件/01_司机_ab12.jpg" in f