fix: 修复测试用例 mock 配置以适配 ai_router 局部导入
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 3s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 55s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m15s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m40s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m1s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 3m27s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Failing after 4m22s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 4m34s
AI Code Review / AI Code Review (pull_request) Successful in 6m53s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 10m35s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 13m18s
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 1s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 10m33s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 3s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 55s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m15s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m40s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m1s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 3m27s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Failing after 4m22s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 4m34s
AI Code Review / AI Code Review (pull_request) Successful in 6m53s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 10m35s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 13m18s
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 1s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 10m33s
This commit is contained in:
@@ -65,6 +65,7 @@ class TestInitConfig:
|
||||
settings.cosyvoice_voice = "test"
|
||||
settings.cosyvoice_clone_model = "voice-enrollment"
|
||||
mock_settings.return_value = settings
|
||||
mock_router.get_tts_client.return_value = None
|
||||
svc = CosyVoiceService(http_client=mock_client)
|
||||
assert svc._base_url == "https://dashscope.aliyuncs.com/api/v1"
|
||||
|
||||
@@ -83,6 +84,7 @@ class TestInitConfig:
|
||||
settings.cosyvoice_voice = "test"
|
||||
settings.cosyvoice_clone_model = "voice-enrollment"
|
||||
mock_settings.return_value = settings
|
||||
mock_router.get_tts_client.return_value = None
|
||||
svc = CosyVoiceService(
|
||||
api_key="sk-custom",
|
||||
base_url="https://custom.example.com/api/v1",
|
||||
@@ -118,6 +120,7 @@ class TestInitConfig:
|
||||
settings.cosyvoice_clone_model = "voice-enrollment"
|
||||
|
||||
mock_settings.return_value = settings
|
||||
mock_router.get_tts_client.return_value = None
|
||||
svc = CosyVoiceService(http_client=mock_client)
|
||||
with svc as s:
|
||||
assert s is svc
|
||||
@@ -147,6 +150,7 @@ class TestInitConfig:
|
||||
settings.cosyvoice_clone_model = "voice-enrollment"
|
||||
|
||||
mock_settings.return_value = settings
|
||||
mock_router.get_tts_client.return_value = None
|
||||
with patch("packages.application.cosyvoice_service.httpx.Client") as mock_cls:
|
||||
mock_instance = MagicMock()
|
||||
mock_cls.return_value = mock_instance
|
||||
@@ -210,6 +214,7 @@ class TestSubmitCloneTask:
|
||||
settings.cosyvoice_clone_model = "voice-enrollment"
|
||||
|
||||
mock_settings.return_value = settings
|
||||
mock_router.get_tts_client.return_value = None
|
||||
svc = CosyVoiceService(http_client=mock_client)
|
||||
with pytest.raises(CosyVoiceAuthError, match="API Key 未配置"):
|
||||
svc.submit_clone_task(audio_url="https://example.com/audio.mp3")
|
||||
@@ -298,6 +303,7 @@ class TestSubmitCloneTask:
|
||||
settings.cosyvoice_clone_model = "voice-enrollment"
|
||||
|
||||
mock_settings.return_value = settings
|
||||
mock_router.get_tts_client.return_value = None
|
||||
signer = MagicMock(return_value="https://signed.example.com/audio.mp3?token=xxx")
|
||||
svc = CosyVoiceService(http_client=mock_client, audio_url_signer=signer)
|
||||
|
||||
@@ -340,6 +346,7 @@ class TestSubmitCloneTask:
|
||||
settings.cosyvoice_clone_model = "voice-enrollment"
|
||||
|
||||
mock_settings.return_value = settings
|
||||
mock_router.get_tts_client.return_value = None
|
||||
signer = MagicMock(side_effect=RuntimeError("sign failed"))
|
||||
svc = CosyVoiceService(http_client=mock_client, audio_url_signer=signer)
|
||||
|
||||
@@ -421,6 +428,7 @@ class TestQueryVoiceStatus:
|
||||
settings.cosyvoice_clone_model = "voice-enrollment"
|
||||
|
||||
mock_settings.return_value = settings
|
||||
mock_router.get_tts_client.return_value = None
|
||||
svc = CosyVoiceService(http_client=mock_client)
|
||||
with pytest.raises(CosyVoiceAuthError):
|
||||
svc.query_voice_status("v1")
|
||||
@@ -638,6 +646,7 @@ class TestSubmitSynthesizeTask:
|
||||
settings.cosyvoice_clone_model = "voice-enrollment"
|
||||
|
||||
mock_settings.return_value = settings
|
||||
mock_router.get_tts_client.return_value = None
|
||||
svc = CosyVoiceService(http_client=mock_client)
|
||||
with pytest.raises(CosyVoiceAuthError):
|
||||
svc.submit_synthesize_task(text="你好", voice_id="v1")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
Reference in New Issue
Block a user