Refactor test files for improved readability and consistency
- Removed unnecessary blank lines and adjusted formatting in test files. - Ensured consistent use of commas in function calls and assertions across various test cases. - Updated import statements for better organization and clarity. - Enhanced mock setups in tests for better isolation and reliability. - Improved assertions to follow a consistent style for better readability.
This commit is contained in:
@@ -8,7 +8,12 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from app.models.sound import Sound
|
||||
from app.utils.audio import get_audio_duration, get_file_hash, get_file_size, get_sound_file_path
|
||||
from app.utils.audio import (
|
||||
get_audio_duration,
|
||||
get_file_hash,
|
||||
get_file_size,
|
||||
get_sound_file_path,
|
||||
)
|
||||
|
||||
|
||||
class TestAudioUtils:
|
||||
@@ -301,7 +306,7 @@ class TestAudioUtils:
|
||||
type="SDB",
|
||||
is_normalized=False,
|
||||
)
|
||||
|
||||
|
||||
result = get_sound_file_path(sound)
|
||||
expected = Path("sounds/originals/soundboard/test.mp3")
|
||||
assert result == expected
|
||||
@@ -310,13 +315,13 @@ class TestAudioUtils:
|
||||
"""Test getting sound file path for SDB type normalized file."""
|
||||
sound = Sound(
|
||||
id=1,
|
||||
name="Test Sound",
|
||||
name="Test Sound",
|
||||
filename="original.mp3",
|
||||
normalized_filename="normalized.mp3",
|
||||
type="SDB",
|
||||
is_normalized=True,
|
||||
)
|
||||
|
||||
|
||||
result = get_sound_file_path(sound)
|
||||
expected = Path("sounds/normalized/soundboard/normalized.mp3")
|
||||
assert result == expected
|
||||
@@ -326,11 +331,11 @@ class TestAudioUtils:
|
||||
sound = Sound(
|
||||
id=2,
|
||||
name="TTS Sound",
|
||||
filename="tts_file.wav",
|
||||
filename="tts_file.wav",
|
||||
type="TTS",
|
||||
is_normalized=False,
|
||||
)
|
||||
|
||||
|
||||
result = get_sound_file_path(sound)
|
||||
expected = Path("sounds/originals/text_to_speech/tts_file.wav")
|
||||
assert result == expected
|
||||
@@ -342,10 +347,10 @@ class TestAudioUtils:
|
||||
name="TTS Sound",
|
||||
filename="original.wav",
|
||||
normalized_filename="normalized.mp3",
|
||||
type="TTS",
|
||||
type="TTS",
|
||||
is_normalized=True,
|
||||
)
|
||||
|
||||
|
||||
result = get_sound_file_path(sound)
|
||||
expected = Path("sounds/normalized/text_to_speech/normalized.mp3")
|
||||
assert result == expected
|
||||
@@ -359,7 +364,7 @@ class TestAudioUtils:
|
||||
type="EXT",
|
||||
is_normalized=False,
|
||||
)
|
||||
|
||||
|
||||
result = get_sound_file_path(sound)
|
||||
expected = Path("sounds/originals/extracted/extracted.mp3")
|
||||
assert result == expected
|
||||
@@ -370,11 +375,11 @@ class TestAudioUtils:
|
||||
id=3,
|
||||
name="Extracted Sound",
|
||||
filename="original.mp3",
|
||||
normalized_filename="normalized.mp3",
|
||||
normalized_filename="normalized.mp3",
|
||||
type="EXT",
|
||||
is_normalized=True,
|
||||
)
|
||||
|
||||
|
||||
result = get_sound_file_path(sound)
|
||||
expected = Path("sounds/normalized/extracted/normalized.mp3")
|
||||
assert result == expected
|
||||
@@ -388,7 +393,7 @@ class TestAudioUtils:
|
||||
type="CUSTOM",
|
||||
is_normalized=False,
|
||||
)
|
||||
|
||||
|
||||
result = get_sound_file_path(sound)
|
||||
expected = Path("sounds/originals/custom/unknown.mp3")
|
||||
assert result == expected
|
||||
@@ -403,7 +408,7 @@ class TestAudioUtils:
|
||||
type="SDB",
|
||||
is_normalized=True, # True but no normalized_filename
|
||||
)
|
||||
|
||||
|
||||
result = get_sound_file_path(sound)
|
||||
# Should fall back to original file
|
||||
expected = Path("sounds/originals/soundboard/original.mp3")
|
||||
|
||||
Reference in New Issue
Block a user