mirror of
https://github.com/remsky/Kokoro-FastAPI.git
synced 2025-08-05 16:48:53 +00:00
Refactor TTS service tests: Update test_get_voice_path_combined to verify path format for combined voices, removing mock for os.path.join and enhancing assertions for path validation.
This commit is contained in:
parent
0b2260602a
commit
f7fb9c524a
1 changed files with 4 additions and 4 deletions
|
@ -94,20 +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 == "/tmp/voice1+voice2.pt"
|
||||
# Verify the path points to a temporary file with expected format
|
||||
assert path.startswith("/tmp/")
|
||||
assert "voice1+voice2" in path
|
||||
assert path.endswith(".pt")
|
||||
mock_save.assert_called_once()
|
||||
mock_join.assert_called_with("/tmp", "voice1+voice2.pt")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
Loading…
Add table
Reference in a new issue