feat(product-suite): support temporary item drafts
This commit is contained in:
@@ -294,6 +294,48 @@ class ImageStudioImageTests(TempDirMixin, unittest.TestCase):
|
||||
|
||||
self.assert_removed(temp_dir)
|
||||
|
||||
def test_draft_import_uses_stable_storage_key_after_formal_binding(self):
|
||||
with self.make_temp_dir() as temp_dir:
|
||||
db_path = os.path.join(temp_dir, "cmshopee.db")
|
||||
db.init_db(db_path)
|
||||
draft = image_studio.create_draft_project(
|
||||
account_alias="alias",
|
||||
account_slug="alias_slug",
|
||||
path=db_path,
|
||||
)
|
||||
config = {
|
||||
"data_dir": temp_dir,
|
||||
"db_path": db_path,
|
||||
"image_dir": os.path.join(temp_dir, "images"),
|
||||
}
|
||||
|
||||
first = image_studio_images.import_original_bytes(
|
||||
draft.id,
|
||||
self._png_bytes(color=(10, 20, 30, 255)),
|
||||
filename_hint="first.png",
|
||||
path=db_path,
|
||||
config=config,
|
||||
)
|
||||
first_path = first.local_path
|
||||
bound = image_studio.bind_draft_project(draft.id, "51100639510", path=db_path)
|
||||
second = image_studio_images.import_original_bytes(
|
||||
bound.id,
|
||||
self._png_bytes(color=(40, 50, 60, 255)),
|
||||
filename_hint="second.png",
|
||||
path=db_path,
|
||||
config=config,
|
||||
)
|
||||
|
||||
self.assertEqual(image_studio.PROJECT_BINDING_BOUND, bound.binding_state)
|
||||
self.assertEqual(draft.storage_key, bound.storage_key)
|
||||
self.assertEqual(os.path.dirname(first_path), os.path.dirname(second.local_path))
|
||||
self.assertTrue(os.path.isfile(first_path))
|
||||
self.assertTrue(os.path.isfile(second.local_path))
|
||||
self.assertIn(draft.storage_key, first_path)
|
||||
self.assertNotIn("51100639510", first_path)
|
||||
|
||||
self.assert_removed(temp_dir)
|
||||
|
||||
def test_import_original_ignores_missing_history_when_enforcing_limit(self):
|
||||
with self.make_temp_dir() as temp_dir:
|
||||
db_path = os.path.join(temp_dir, "cmshopee.db")
|
||||
|
||||
Reference in New Issue
Block a user