feat: 执行并提交 PDD 采集任务 (#32)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""用真机导出的控件树验证真实页面结构。"""
|
||||
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
from src.pdd_collect_service import parse_goods_page, parse_spec_panel
|
||||
|
||||
|
||||
REAL_XML = Path(__file__).parents[1] / "image_xml"
|
||||
|
||||
|
||||
class PddRealXmlFixtureTest(unittest.TestCase):
|
||||
def test_split_title_is_joined_from_real_goods_page(self):
|
||||
result = parse_goods_page(
|
||||
(REAL_XML / "737116531267_home.xml").read_text(encoding="utf-8")
|
||||
)
|
||||
self.assertEqual(
|
||||
result.title,
|
||||
"【店铺热销】冰丝吊带裙女夏季薄款内搭连衣裙宽松a字裙中长款打底裙衬裙纯色",
|
||||
)
|
||||
|
||||
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")
|
||||
)
|
||||
colors = next(item for item in result.dimensions if item.key == "color")
|
||||
|
||||
self.assertEqual(len(colors.values), 8)
|
||||
self.assertIn("浅蓝色中长款", [item.text for item in colors.values])
|
||||
self.assertEqual(result.price_cent, 470)
|
||||
self.assertEqual(result.list_price_cent, 1990)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user