fix: filter title model from outfit picker
This commit is contained in:
@@ -174,6 +174,81 @@ class TestAiOutfitPanelDefaults(unittest.TestCase):
|
||||
self.assertIsInstance(config, AiModelConfig)
|
||||
self.assertEqual(config.model, "gpt-5.5")
|
||||
|
||||
def test_image_model_combo_filters_configured_title_model(self):
|
||||
"""§19.29: 图片 AI 模型下拉不显示 app_config.title_model 同名模型。"""
|
||||
panel = self._panel()
|
||||
panel._models = [
|
||||
{"name": "GPT-5.5 文本", "url": "https://r/v1/chat/completions",
|
||||
"model": "gpt-5.5", "api_key": "sk-x", "api_type": "chat"},
|
||||
{"name": "GPT Image 2", "url": "https://r/v1/images/edits",
|
||||
"model": "gpt-image", "api_key": "sk-y", "api_type": "images_edits"},
|
||||
{"name": "Nano Banana 2", "url": "https://r/v1/chat/completions",
|
||||
"model": "nano", "api_key": "sk-z", "api_type": "auto"},
|
||||
]
|
||||
panel._title_model_name = "GPT-5.5 文本"
|
||||
|
||||
panel._fill_model_combo(panel._model_combo, "GPT-5.5 文本")
|
||||
|
||||
names = [panel._model_combo.itemText(i) for i in range(panel._model_combo.count())]
|
||||
self.assertNotIn("GPT-5.5 文本", names)
|
||||
self.assertEqual(names, ["GPT Image 2", "Nano Banana 2"])
|
||||
self.assertEqual(panel._model_combo.currentText(), "GPT Image 2")
|
||||
self.assertTrue(panel._model_combo.isEnabled())
|
||||
self.assertEqual(panel._model_combo.currentData()["name"], "GPT Image 2")
|
||||
|
||||
def test_selected_model_config_uses_filtered_combo_data(self):
|
||||
"""Filtered combo indices no longer match self._models; use item data."""
|
||||
panel = self._panel()
|
||||
panel._models = [
|
||||
{"name": "GPT-5.5 文本", "url": "https://r/v1/chat/completions",
|
||||
"model": "gpt-5.5", "api_key": "sk-x", "api_type": "chat"},
|
||||
{"name": "GPT Image 2", "url": "https://r/v1/images/edits",
|
||||
"model": "gpt-image", "api_key": "sk-y", "api_type": "images_edits"},
|
||||
{"name": "Nano Banana 2", "url": "https://r/v1/chat/completions",
|
||||
"model": "nano", "api_key": "sk-z", "api_type": "auto"},
|
||||
]
|
||||
panel._title_model_name = "GPT-5.5 文本"
|
||||
|
||||
panel._fill_model_combo(panel._model_combo, "Nano Banana 2")
|
||||
config = panel._selected_model_config()
|
||||
|
||||
self.assertEqual(config.model, "nano")
|
||||
|
||||
def test_image_model_combo_keeps_title_model_available_for_title_generation(self):
|
||||
"""Filtering the image dropdown must not remove the title model from self._models."""
|
||||
from services.ai_image_service import AiModelConfig
|
||||
|
||||
panel = self._panel()
|
||||
panel._models = [
|
||||
{"name": "GPT-5.5 文本", "url": "https://r/v1/chat/completions",
|
||||
"model": "gpt-5.5", "api_key": "sk-x", "api_type": "chat"},
|
||||
{"name": "GPT Image 2", "url": "https://r/v1/images/edits",
|
||||
"model": "gpt-image", "api_key": "sk-y", "api_type": "images_edits"},
|
||||
]
|
||||
panel._title_model_name = "GPT-5.5 文本"
|
||||
|
||||
panel._fill_model_combo(panel._model_combo, "GPT Image 2")
|
||||
config, error = panel._find_title_model()
|
||||
|
||||
self.assertIsNone(error)
|
||||
self.assertIsInstance(config, AiModelConfig)
|
||||
self.assertEqual(config.model, "gpt-5.5")
|
||||
|
||||
def test_image_model_combo_only_title_model_shows_placeholder(self):
|
||||
panel = self._panel()
|
||||
panel._models = [
|
||||
{"name": "GPT-5.5 文本", "url": "https://r/v1/chat/completions",
|
||||
"model": "gpt-5.5", "api_key": "sk-x", "api_type": "chat"},
|
||||
]
|
||||
panel._title_model_name = "GPT-5.5 文本"
|
||||
|
||||
panel._fill_model_combo(panel._model_combo, "")
|
||||
|
||||
self.assertEqual(panel._model_combo.count(), 1)
|
||||
self.assertIn("未配置可用图片模型", panel._model_combo.currentText())
|
||||
self.assertFalse(panel._model_combo.isEnabled())
|
||||
self.assertIsNone(panel._model_combo.currentData())
|
||||
|
||||
def test_find_title_model_missing_name_errors(self):
|
||||
panel = self._panel()
|
||||
panel._models = [{"name": "别的模型", "url": "https://r/v1/chat/completions",
|
||||
|
||||
Reference in New Issue
Block a user