fix: 蛇形遍历颜色并逐色采价 (#37)

This commit is contained in:
chengma
2026-08-08 09:25:40 +08:00
parent e08fd89c91
commit 9562da9aad
7 changed files with 668 additions and 202 deletions
+20 -2
View File
@@ -65,9 +65,10 @@ class PddRealXmlFixtureTest(unittest.TestCase):
)
def test_real_spec_panel_has_all_colors_and_two_prices(self):
result = parse_spec_panel(
(REAL_XML / "737116531267_size.xml").read_text(encoding="utf-8")
xml_data = (REAL_XML / "737116531267_size.xml").read_text(
encoding="utf-8"
)
result = parse_spec_panel(xml_data)
colors = next(item for item in result.dimensions if item.key == "color")
self.assertEqual(len(colors.values), 8)
@@ -75,6 +76,23 @@ class PddRealXmlFixtureTest(unittest.TestCase):
self.assertEqual(result.price_cent, 470)
self.assertEqual(result.list_price_cent, 1990)
service = PddCollectService(
PddDeviceService(lambda _serial: object()),
"USB-001",
"client-001",
max_spec_swipes=0,
)
rows = service._visible_color_rows(xml_data)
self.assertEqual(len(rows), 2)
self.assertEqual(
[item.text for item in rows[0]],
["黑色中长款", "白色中长款", "卡其中长款"],
)
self.assertEqual(
[item.text for item in rows[1]],
["黑色长款", "白色长款", "卡其长款"],
)
def test_real_home_xml_has_immediate_spec_entry(self):
xml_data = (REAL_XML / "737116531267_home.xml").read_text(
encoding="utf-8"