feat: [workflow] 统一飞书款式身份配置

This commit is contained in:
2026-09-07 15:01:04 +08:00
parent 92289b17ed
commit 485e77ee74
13 changed files with 1153 additions and 135 deletions
+102
View File
@@ -0,0 +1,102 @@
from gyxx_flow.migration.sync_feishu_style_identity import (
StyleIdentity,
_merge_target_row,
build_sync_plan,
)
def _row(record_id: str, **config):
return {"source_record_id": record_id, "config": config}
def test_build_sync_plan_groups_platform_rows_and_deduplicates_ids():
styles, report = build_sync_plan(
[
_row(
"tm-1",
style_name=" 极星pro ",
brand="光影行星",
erp_codes="10398,10398",
platform="天猫",
item_ids="TM-1,TM-2",
),
_row(
"jd-1",
style_name="极星pro",
brand="光影行星",
erp_codes=["10398"],
platform="京东旗舰店",
item_ids=["JD-1", "JD-1"],
),
]
)
assert [style.name for style in styles] == ["极星pro"]
assert styles[0].erp_codes == ["10398"]
assert styles[0].platform_product_ids == {
"tm": ["TM-1", "TM-2"],
"jd": ["JD-1"],
"jd_self": [],
"dy": [],
}
assert report["collectable_styles"] == ["极星pro"]
def test_build_sync_plan_reports_unknown_platform_and_blank_style():
styles, report = build_sync_plan(
[
_row(
"pdd-1",
style_name="宙斯",
brand="光影行星",
erp_codes="10489",
platform="拼多多",
item_ids="PDD-1",
),
_row(
"blank-1",
style_name="",
brand="",
erp_codes="",
platform="天猫",
item_ids="",
),
]
)
assert [style.name for style in styles] == ["宙斯"]
assert report["unknown_platform_rows"] == [
{
"style": "宙斯",
"platform": "拼多多",
"item_count": 1,
"record_id": "pdd-1",
}
]
assert report["skipped_rows"] == [
{"record_id": "blank-1", "reason": "款式名称为空"}
]
def test_merge_target_row_does_not_erase_existing_identity_with_blank_source():
style = StyleIdentity(name="宙斯")
merged = _merge_target_row(
style,
{
"name": "宙斯",
"brand": "光影行星",
"erp_style_codes": ["10489"],
"platform_product_ids": {
"天猫": ["OLD-TM"],
"tm": ["TM-1"],
"jd": ["JD-1"],
},
},
)
assert merged["brand"] == "光影行星"
assert merged["erp_style_codes"] == ["10489"]
assert merged["platform_product_ids"]["tm"] == ["TM-1"]
assert merged["platform_product_ids"]["jd"] == ["JD-1"]
assert merged["platform_product_ids"]["jd_self"] == []
assert merged["platform_product_ids"]["dy"] == []