feat(ai-studio): add main workspace tab
This commit is contained in:
@@ -210,6 +210,35 @@ class ImageStudioTests(TempDirMixin, unittest.TestCase):
|
||||
|
||||
self.assert_removed(temp_dir)
|
||||
|
||||
def test_remove_asset_only_when_not_referenced(self):
|
||||
with self.make_temp_dir() as temp_dir:
|
||||
db_path = os.path.join(temp_dir, "cmshopee.db")
|
||||
db.init_db(db_path)
|
||||
project = image_studio.create_or_get_project(
|
||||
account_alias="alias",
|
||||
account_slug="alias_slug",
|
||||
item_id="51100639510",
|
||||
path=db_path,
|
||||
)
|
||||
free_asset = image_studio.add_asset(project.id, "original", path=db_path)
|
||||
referenced_asset = image_studio.add_asset(project.id, "original", path=db_path)
|
||||
image_studio.create_job(
|
||||
project.id,
|
||||
source_asset_id=referenced_asset.id,
|
||||
path=db_path,
|
||||
)
|
||||
|
||||
counts = image_studio.asset_reference_counts(referenced_asset.id, path=db_path)
|
||||
self.assertEqual(1, counts["source_job"])
|
||||
with self.assertRaisesRegex(db.DbError, "引用"):
|
||||
image_studio.remove_asset_if_unused(referenced_asset.id, path=db_path)
|
||||
|
||||
removed = image_studio.remove_asset_if_unused(free_asset.id, path=db_path)
|
||||
self.assertEqual(free_asset.id, removed.id)
|
||||
self.assertIsNone(image_studio.get_asset(free_asset.id, path=db_path))
|
||||
|
||||
self.assert_removed(temp_dir)
|
||||
|
||||
def test_sync_original_asset_urls_is_idempotent_and_marks_missing(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