feat(ai): enforce direct image edit contract
This commit is contained in:
@@ -635,6 +635,40 @@ class AppConfigTests(TempDirMixin, unittest.TestCase):
|
||||
),
|
||||
)
|
||||
|
||||
def test_image_model_config_check_keeps_legacy_models_but_blocks_them_for_generation(self):
|
||||
with self.make_temp_dir() as temp_dir:
|
||||
models_path = os.path.join(temp_dir, "ai_models.json")
|
||||
config = appconfig.default_ai_models_config()
|
||||
legacy_image = config["models"][1]
|
||||
legacy_image.update(
|
||||
{
|
||||
"url": "https://legacy.example.com/v1/chat/completions",
|
||||
"model": "legacy-image",
|
||||
"api_key": "sk-legacy-secret",
|
||||
"api_type": "auto",
|
||||
}
|
||||
)
|
||||
appconfig.save_ai_models_config(config, path=models_path)
|
||||
|
||||
loaded = appconfig.get_model("Nano Banana 2", path=models_path)
|
||||
self.assertEqual("auto", loaded["api_type"])
|
||||
result = appconfig.check_image_model_config("Nano Banana 2", path=models_path)
|
||||
self.assertFalse(result["ok"])
|
||||
self.assertTrue(result["check_only"])
|
||||
self.assertIn("OpenAI 图片编辑接口", result["error"])
|
||||
self.assertNotIn("sk-legacy-secret", result["error"])
|
||||
|
||||
appconfig.update_ai_model(
|
||||
"Nano Banana 2",
|
||||
path=models_path,
|
||||
api_type="images_edits",
|
||||
)
|
||||
self.assertTrue(
|
||||
appconfig.check_image_model_config("Nano Banana 2", path=models_path)["ok"]
|
||||
)
|
||||
|
||||
self.assert_removed(temp_dir)
|
||||
|
||||
def test_ai_model_test_uses_resolved_base_url(self):
|
||||
with self.make_temp_dir() as temp_dir:
|
||||
models_path = os.path.join(temp_dir, "ai_models.json")
|
||||
|
||||
Reference in New Issue
Block a user