feat(ai-studio): clarify hosted model tiers
This commit is contained in:
@@ -41,6 +41,7 @@ from app.gui import (
|
||||
WriteBackWorker,
|
||||
)
|
||||
from app.gui import file_manager
|
||||
import app.gui.workers as gui_workers
|
||||
from app.gui.tabs.generate import CoverGalleryDialog, OriginalImageDialog
|
||||
from app.gui.main_window import _fit_and_center_window
|
||||
|
||||
@@ -649,6 +650,73 @@ class GuiTests(TempDirMixin, unittest.TestCase):
|
||||
|
||||
self.assert_removed(temp_dir)
|
||||
|
||||
def test_image_studio_generation_log_uses_cmhub_tier_summary(self):
|
||||
with self.make_temp_dir() as temp_dir:
|
||||
cfg = self.make_config(temp_dir)
|
||||
cfg["ai"] = appconfig.ai_config(cfg)
|
||||
cfg["ai"]["backend"] = "cmhub"
|
||||
cfg["ai"]["cmhub"]["image_alias"] = "image-hd"
|
||||
db.init_db(cfg["db_path"])
|
||||
project = image_studio.create_or_get_project(
|
||||
account_alias="alias-a",
|
||||
account_slug="alias_a",
|
||||
item_id="51100639510",
|
||||
path=cfg["db_path"],
|
||||
)
|
||||
source = image_studio.add_asset(
|
||||
project.id,
|
||||
"original",
|
||||
local_path=self.write_test_image(os.path.join(temp_dir, "source.jpg")),
|
||||
path=cfg["db_path"],
|
||||
)
|
||||
tab = ImageStudioTab(config=cfg, db_path=cfg["db_path"])
|
||||
self.addCleanup(tab.close)
|
||||
tab._select_project(project.id)
|
||||
tab._select_source_asset(source)
|
||||
tab.prompt_edit.setPlainText("生成商品主图")
|
||||
|
||||
class FakeStudioWorker:
|
||||
def __init__(self):
|
||||
self.progress = DummySignal()
|
||||
self.log = DummySignal()
|
||||
self.finished = DummySignal()
|
||||
self.failed = DummySignal()
|
||||
|
||||
def cancel(self):
|
||||
pass
|
||||
|
||||
fake_worker = FakeStudioWorker()
|
||||
with mock.patch(
|
||||
"app.gui.tabs.image_studio.ImageStudioGenerateJobsWorker",
|
||||
return_value=fake_worker,
|
||||
), mock.patch("app.gui.tabs.image_studio.run_worker", return_value=FakeThread()):
|
||||
tab.start_generation()
|
||||
|
||||
log_text = tab.log_view.toPlainText()
|
||||
self.assertIn("cmhub 托管高质量档", log_text)
|
||||
self.assertIn("生图别名 image-hd", log_text)
|
||||
tab._on_generate_progress({"points_balance": 66, "points_cost": 2})
|
||||
self.assertIn("高质量档", tab.billing_label.text())
|
||||
self.assertIn("余额 66", tab.billing_label.text())
|
||||
self.assertIn("本张扣点 2", tab.billing_label.text())
|
||||
|
||||
self.assert_removed(temp_dir)
|
||||
|
||||
def test_image_studio_event_log_hides_provider_urls(self):
|
||||
message = gui_workers._format_image_studio_event(
|
||||
{
|
||||
"step": "cover_poll",
|
||||
"result": "failed",
|
||||
"detail": "GET https://cmhub.example.com/api/v1/generate/image/tasks/t1 failed /generated/images/a.png",
|
||||
}
|
||||
)
|
||||
|
||||
self.assertIn("请求 cmhub", message)
|
||||
self.assertIn("[接口路径已隐藏]", message)
|
||||
self.assertNotIn("https://", message)
|
||||
self.assertNotIn("/api/v1", message)
|
||||
self.assertNotIn("/generated/images", message)
|
||||
|
||||
def test_startup_update_gate_forced_blocks_and_opens_download(self):
|
||||
boxes = []
|
||||
|
||||
@@ -1793,8 +1861,10 @@ class GuiTests(TempDirMixin, unittest.TestCase):
|
||||
self.assertIn("title-priced", title_aliases)
|
||||
self.assertIn("title-saved", title_aliases)
|
||||
self.assertNotIn("title-free", title_aliases)
|
||||
self.assertIn("默认档", tab.cmhub_title_alias_combo.itemText(0))
|
||||
self.assertIn("512:1点", tab.cmhub_title_alias_combo.itemText(0))
|
||||
self.assertTrue(any("需参考图" in label for label in image_labels))
|
||||
self.assertTrue(any("默认档" in label for label in image_labels))
|
||||
self.assertIn("余额 55", tab.cmhub_result_label.text())
|
||||
|
||||
self.assert_removed(temp_dir)
|
||||
|
||||
Reference in New Issue
Block a user