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:
@@ -10,12 +10,12 @@ from app.core.dependencies import get_current_active_user_flexible
|
||||
from app.models.credit_action import CreditActionType
|
||||
from app.models.user import User
|
||||
from app.repositories.sound import SoundRepository
|
||||
from app.services.extraction import ExtractionInfo, ExtractionService
|
||||
from app.services.credit import CreditService, InsufficientCreditsError
|
||||
from app.services.extraction import ExtractionInfo, ExtractionService
|
||||
from app.services.extraction_processor import extraction_processor
|
||||
from app.services.sound_normalizer import NormalizationResults, SoundNormalizerService
|
||||
from app.services.sound_scanner import ScanResults, SoundScannerService
|
||||
from app.services.vlc_player import get_vlc_player_service, VLCPlayerService
|
||||
from app.services.vlc_player import VLCPlayerService, get_vlc_player_service
|
||||
|
||||
router = APIRouter(prefix="/sounds", tags=["sounds"])
|
||||
|
||||
@@ -125,13 +125,13 @@ async def scan_custom_directory(
|
||||
async def normalize_all_sounds(
|
||||
current_user: Annotated[User, Depends(get_current_active_user_flexible)],
|
||||
normalizer_service: Annotated[
|
||||
SoundNormalizerService, Depends(get_sound_normalizer_service)
|
||||
SoundNormalizerService, Depends(get_sound_normalizer_service),
|
||||
],
|
||||
force: bool = Query(
|
||||
False, description="Force normalization of already normalized sounds"
|
||||
False, description="Force normalization of already normalized sounds",
|
||||
),
|
||||
one_pass: bool | None = Query(
|
||||
None, description="Use one-pass normalization (overrides config)"
|
||||
None, description="Use one-pass normalization (overrides config)",
|
||||
),
|
||||
) -> dict[str, NormalizationResults | str]:
|
||||
"""Normalize all unnormalized sounds."""
|
||||
@@ -163,13 +163,13 @@ async def normalize_sounds_by_type(
|
||||
sound_type: str,
|
||||
current_user: Annotated[User, Depends(get_current_active_user_flexible)],
|
||||
normalizer_service: Annotated[
|
||||
SoundNormalizerService, Depends(get_sound_normalizer_service)
|
||||
SoundNormalizerService, Depends(get_sound_normalizer_service),
|
||||
],
|
||||
force: bool = Query(
|
||||
False, description="Force normalization of already normalized sounds"
|
||||
False, description="Force normalization of already normalized sounds",
|
||||
),
|
||||
one_pass: bool | None = Query(
|
||||
None, description="Use one-pass normalization (overrides config)"
|
||||
None, description="Use one-pass normalization (overrides config)",
|
||||
),
|
||||
) -> dict[str, NormalizationResults | str]:
|
||||
"""Normalize all sounds of a specific type (SDB, TTS, EXT)."""
|
||||
@@ -210,13 +210,13 @@ async def normalize_sound_by_id(
|
||||
sound_id: int,
|
||||
current_user: Annotated[User, Depends(get_current_active_user_flexible)],
|
||||
normalizer_service: Annotated[
|
||||
SoundNormalizerService, Depends(get_sound_normalizer_service)
|
||||
SoundNormalizerService, Depends(get_sound_normalizer_service),
|
||||
],
|
||||
force: bool = Query(
|
||||
False, description="Force normalization of already normalized sound"
|
||||
False, description="Force normalization of already normalized sound",
|
||||
),
|
||||
one_pass: bool | None = Query(
|
||||
None, description="Use one-pass normalization (overrides config)"
|
||||
None, description="Use one-pass normalization (overrides config)",
|
||||
),
|
||||
) -> dict[str, str]:
|
||||
"""Normalize a specific sound by ID."""
|
||||
@@ -283,7 +283,7 @@ async def create_extraction(
|
||||
)
|
||||
|
||||
extraction_info = await extraction_service.create_extraction(
|
||||
url, current_user.id
|
||||
url, current_user.id,
|
||||
)
|
||||
|
||||
# Queue the extraction for background processing
|
||||
@@ -398,7 +398,7 @@ async def play_sound_with_vlc(
|
||||
await credit_service.validate_and_reserve_credits(
|
||||
current_user.id,
|
||||
CreditActionType.VLC_PLAY_SOUND,
|
||||
{"sound_id": sound_id, "sound_name": sound.name}
|
||||
{"sound_id": sound_id, "sound_name": sound.name},
|
||||
)
|
||||
except InsufficientCreditsError as e:
|
||||
raise HTTPException(
|
||||
@@ -408,7 +408,7 @@ async def play_sound_with_vlc(
|
||||
|
||||
# Play the sound using VLC
|
||||
success = await vlc_player.play_sound(sound)
|
||||
|
||||
|
||||
# Deduct credits based on success
|
||||
await credit_service.deduct_credits(
|
||||
current_user.id,
|
||||
@@ -416,7 +416,7 @@ async def play_sound_with_vlc(
|
||||
success,
|
||||
{"sound_id": sound_id, "sound_name": sound.name},
|
||||
)
|
||||
|
||||
|
||||
if not success:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
|
||||
Reference in New Issue
Block a user