feat(product-suite): refine history account filters
This commit is contained in:
@@ -1208,6 +1208,30 @@ class ImageStudioTests(TempDirMixin, unittest.TestCase):
|
||||
)
|
||||
],
|
||||
)
|
||||
self.assertEqual(
|
||||
["main-shop", "second-shop"],
|
||||
[
|
||||
account.account_alias
|
||||
for account in image_studio.list_global_history_accounts(path=db_path)
|
||||
],
|
||||
)
|
||||
self.assertEqual(
|
||||
[first_project.id, first_project.id],
|
||||
[
|
||||
round_.project_id
|
||||
for round_ in image_studio.list_global_generation_rounds(
|
||||
account_alias="main-shop",
|
||||
path=db_path,
|
||||
)
|
||||
],
|
||||
)
|
||||
self.assertEqual(
|
||||
[],
|
||||
image_studio.list_global_generation_rounds(
|
||||
account_alias="main",
|
||||
path=db_path,
|
||||
),
|
||||
)
|
||||
self.assertEqual(
|
||||
[second_project.id],
|
||||
[
|
||||
|
||||
@@ -185,17 +185,12 @@ class ProductSuiteGuiTests(TempDirMixin, unittest.TestCase):
|
||||
tab.context_bar_layout.indexOf(tab.history_button),
|
||||
tab.context_bar_layout.indexOf(tab.account_combo),
|
||||
)
|
||||
self.assertLess(
|
||||
tab.context_bar_layout.indexOf(tab.open_folder_button),
|
||||
tab.context_bar_layout.indexOf(tab.account_combo),
|
||||
)
|
||||
self.assertLess(
|
||||
tab.context_bar_layout.indexOf(tab.add_images_button),
|
||||
tab.context_bar_layout.indexOf(tab.account_combo),
|
||||
)
|
||||
self.assertEqual(-1, tab.results_toolbar_layout.indexOf(tab.history_button))
|
||||
self.assertEqual(-1, tab.results_toolbar_layout.indexOf(tab.open_folder_button))
|
||||
self.assertEqual("打开结果文件夹", tab.open_folder_button.text())
|
||||
self.assertFalse(hasattr(tab, "open_folder_button"))
|
||||
self.assertEqual("合计 5 张", tab.category_total_label.text())
|
||||
self.assertEqual("生成套图(5)", tab.generate_button.text())
|
||||
self.assertLess(
|
||||
@@ -218,6 +213,7 @@ class ProductSuiteGuiTests(TempDirMixin, unittest.TestCase):
|
||||
)
|
||||
self.assertNotIn("详情图", visible_text)
|
||||
self.assertNotIn("AI工场", visible_text)
|
||||
self.assertNotIn("打开结果文件夹", visible_text)
|
||||
self.assertIn("白底图", visible_text)
|
||||
self.assertIn("场景图", visible_text)
|
||||
self.assertIn("卖点图", visible_text)
|
||||
@@ -1986,18 +1982,40 @@ class ProductSuiteGuiTests(TempDirMixin, unittest.TestCase):
|
||||
config = self._config(temp_dir)
|
||||
project, sources = self._create_project_with_assets(temp_dir, config, 1)
|
||||
source = sources[0]
|
||||
other_account = accounts.create_account(
|
||||
"副店",
|
||||
"other-shop",
|
||||
debug_port=9223,
|
||||
config=config,
|
||||
)
|
||||
accounts.create_account(
|
||||
"空店",
|
||||
"empty-shop",
|
||||
debug_port=9224,
|
||||
config=config,
|
||||
)
|
||||
other_project = image_studio.create_or_get_project(
|
||||
account_alias="other-shop",
|
||||
account_name="副店",
|
||||
account_slug="other-shop",
|
||||
other_account,
|
||||
item_id="51100639511",
|
||||
path=config["db_path"],
|
||||
)
|
||||
former_project = image_studio.create_or_get_project(
|
||||
account_alias="former-shop",
|
||||
account_name="旧店",
|
||||
account_slug="former-shop",
|
||||
item_id="51100639512",
|
||||
path=config["db_path"],
|
||||
)
|
||||
other_source = image_studio.add_asset(
|
||||
other_project.id,
|
||||
image_studio.ASSET_KIND_ORIGINAL,
|
||||
path=config["db_path"],
|
||||
)
|
||||
former_source = image_studio.add_asset(
|
||||
former_project.id,
|
||||
image_studio.ASSET_KIND_ORIGINAL,
|
||||
path=config["db_path"],
|
||||
)
|
||||
for index in range(7):
|
||||
image_path = os.path.join(temp_dir, "global-%d.png" % index)
|
||||
self._write_image(image_path)
|
||||
@@ -2021,6 +2039,17 @@ class ProductSuiteGuiTests(TempDirMixin, unittest.TestCase):
|
||||
local_path=other_path,
|
||||
job_type="卖点图",
|
||||
)
|
||||
former_path = os.path.join(temp_dir, "former-global.png")
|
||||
self._write_image(former_path)
|
||||
self._create_history_job(
|
||||
former_project,
|
||||
former_source,
|
||||
config["db_path"],
|
||||
round_key="former-round",
|
||||
slot_index=0,
|
||||
local_path=former_path,
|
||||
job_type="白底图",
|
||||
)
|
||||
image_studio.set_current_generation_round(
|
||||
project.id,
|
||||
"main-round",
|
||||
@@ -2034,7 +2063,28 @@ class ProductSuiteGuiTests(TempDirMixin, unittest.TestCase):
|
||||
dialog.show()
|
||||
self.app.processEvents()
|
||||
|
||||
self.assertEqual(2, dialog._round_count)
|
||||
self.assertEqual(3, dialog._round_count)
|
||||
self.assertEqual("全部店铺", dialog.account_filter_combo.itemText(0))
|
||||
main_account_index = dialog.account_filter_combo.findData("alias-a")
|
||||
other_account_index = dialog.account_filter_combo.findData("other-shop")
|
||||
empty_account_index = dialog.account_filter_combo.findData("empty-shop")
|
||||
former_account_index = dialog.account_filter_combo.findData("former-shop")
|
||||
self.assertGreaterEqual(main_account_index, 0)
|
||||
self.assertGreaterEqual(other_account_index, 0)
|
||||
self.assertGreaterEqual(empty_account_index, 0)
|
||||
self.assertGreaterEqual(former_account_index, 0)
|
||||
self.assertEqual(
|
||||
"主店(alias-a)",
|
||||
dialog.account_filter_combo.itemText(main_account_index),
|
||||
)
|
||||
self.assertEqual(
|
||||
"副店(other-shop)",
|
||||
dialog.account_filter_combo.itemText(other_account_index),
|
||||
)
|
||||
self.assertEqual(
|
||||
"历史店铺:former-shop(账号已删除)",
|
||||
dialog.account_filter_combo.itemText(former_account_index),
|
||||
)
|
||||
rows = dialog.findChildren(SuiteGlobalHistoryRoundRow)
|
||||
main_row = next(
|
||||
row for row in rows if row.round_info.project_id == project.id
|
||||
@@ -2057,8 +2107,7 @@ class ProductSuiteGuiTests(TempDirMixin, unittest.TestCase):
|
||||
dialog._preview_round(main_row, 1)
|
||||
preview.assert_called_once_with()
|
||||
|
||||
dialog.account_filter_edit.setText("副店")
|
||||
dialog.refresh_history()
|
||||
dialog.account_filter_combo.setCurrentIndex(other_account_index)
|
||||
self.app.processEvents()
|
||||
self.assertEqual(1, dialog._round_count)
|
||||
self.assertEqual(
|
||||
@@ -2066,7 +2115,14 @@ class ProductSuiteGuiTests(TempDirMixin, unittest.TestCase):
|
||||
[row.round_info.project_id for row in dialog._history_rows],
|
||||
)
|
||||
|
||||
dialog.account_filter_edit.clear()
|
||||
dialog.item_filter_edit.setText("51100639511")
|
||||
dialog.refresh_history()
|
||||
self.app.processEvents()
|
||||
self.assertEqual(1, dialog._round_count)
|
||||
self.assertEqual("other-shop", dialog.account_filter_combo.currentData())
|
||||
|
||||
dialog.item_filter_edit.clear()
|
||||
dialog.account_filter_combo.setCurrentIndex(0)
|
||||
dialog.current_project_checkbox.setChecked(True)
|
||||
self.app.processEvents()
|
||||
self.assertEqual(1, dialog._round_count)
|
||||
|
||||
Reference in New Issue
Block a user