diff --git a/tests/unit/test_shared_ai_service.py b/tests/unit/test_shared_ai_service.py index f46002dbf..7603a90bb 100755 --- a/tests/unit/test_shared_ai_service.py +++ b/tests/unit/test_shared_ai_service.py @@ -431,7 +431,8 @@ class TestAiCoverService: result = _call_ai_cover_service("plan1", ["a1"], "manual", frame_time=5.5) assert result["type"] == "manual" assert result["frame_time"] == 5.5 - assert "5.5" in result["image_url"] + assert result["image_url"].startswith("data:image/svg+xml,") + assert "手动选帧" in result["image_url"] def test_cover_type_ai_frame(self): with patch("shared.ai_service.time.sleep"): @@ -440,7 +441,8 @@ class TestAiCoverService: assert result["type"] == "ai_frame" assert result["frame_time"] == 5.0 assert result["confidence"] == 0.9 - assert "plan1" in result["image_url"] + assert result["image_url"].startswith("data:image/svg+xml,") + assert "封面生成中" in result["image_url"] def test_cover_type_ai_regenerate(self): with patch("shared.ai_service.time.sleep"): @@ -451,3 +453,20 @@ class TestAiCoverService: with patch("shared.ai_service.time.sleep"): result = _call_ai_cover_service("plan1", ["a1"], "ai_frame") assert 1.0 <= result["frame_time"] <= 10.0 + + def test_stub_returns_svg_data_uri(self): + """stub 降级返回 SVG data URI,不含任何后端 API 路径.""" + with patch("shared.ai_service.time.sleep"): + result = _call_ai_cover_service("plan1", ["a1"], "ai_frame") + assert result["image_url"].startswith("data:image/svg+xml,") + assert "/api/v1/" not in result["image_url"] + assert "1080" in result["image_url"] + assert "1920" in result["image_url"] + + def test_manual_stub_returns_svg_data_uri(self): + """manual 模式返回 SVG data URI 占位图.""" + with patch("shared.ai_service.time.sleep"): + result = _call_ai_cover_service("plan1", ["a1"], "manual", frame_time=3.0) + assert result["image_url"].startswith("data:image/svg+xml,") + assert "/api/v1/" not in result["image_url"] + assert "手动选帧" in result["image_url"]