From 0b2260602ad4e12ac91c381d4f33942db25e6743 Mon Sep 17 00:00:00 2001 From: Lukin Date: Sun, 1 Jun 2025 10:28:35 +0800 Subject: [PATCH] Update TTS service tests: Enhance test_get_voice_path_combined by mocking os.path.join to ensure correct path generation for combined voices. --- api/tests/test_tts_service.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/tests/test_tts_service.py b/api/tests/test_tts_service.py index ae8447a..23b5273 100644 --- a/api/tests/test_tts_service.py +++ b/api/tests/test_tts_service.py @@ -3,6 +3,7 @@ from unittest.mock import AsyncMock, MagicMock, patch import numpy as np import pytest import torch +import os from api.src.services.tts_service import TTSService @@ -93,17 +94,20 @@ async def test_get_voice_path_combined(): patch("torch.load") as mock_load, patch("torch.save") as mock_save, patch("tempfile.gettempdir") as mock_temp, + patch("os.path.join") as mock_join, ): mock_get_model.return_value = model_manager mock_get_voice.return_value = voice_manager mock_temp.return_value = "/tmp" + mock_join.return_value = "/tmp/voice1+voice2.pt" mock_load.return_value = torch.ones(10) service = await TTSService.create("test_output") name, path = await service._get_voices_path("voice1+voice2") assert name == "voice1+voice2" - assert path.endswith("voice1+voice2.pt") + assert path == "/tmp/voice1+voice2.pt" mock_save.assert_called_once() + mock_join.assert_called_with("/tmp", "voice1+voice2.pt") @pytest.mark.asyncio