fix(product-suite): validate item id before generation

This commit is contained in:
chengma
2026-07-22 18:14:50 +08:00
parent 189b5855e9
commit 01b4a05c26
8 changed files with 129 additions and 45 deletions
+11
View File
@@ -23,6 +23,17 @@ class ImageStudioTests(TempDirMixin, unittest.TestCase):
"cdp_ready_timeout": 1,
}
def test_formal_item_id_normalization_removes_format_characters_only(self):
zero_width_item_id = "51100639510" + chr(0x200B)
self.assertEqual(
"51100639510",
image_studio.normalize_item_id_input(" " + zero_width_item_id + " "),
)
self.assertTrue(image_studio.is_formal_item_id(zero_width_item_id))
self.assertFalse(image_studio.is_formal_item_id("51100639510-1"))
self.assertFalse(image_studio.is_formal_item_id("商品51100639510"))
self.assertFalse(image_studio.is_formal_item_id("123"))
def test_init_db_adds_image_studio_tables_without_breaking_existing_tables(self):
with self.make_temp_dir() as temp_dir:
db_path = os.path.join(temp_dir, "cmshopee.db")