Refactor sound and extraction services to include user and timestamp fields
All checks were successful
Backend CI / lint (push) Successful in 18m8s
Backend CI / test (push) Successful in 53m35s

- Updated ExtractionInfo to include user_id, created_at, and updated_at fields.
- Modified ExtractionService to return user and timestamp information in extraction responses.
- Enhanced sound serialization in PlayerState to include extraction URL if available.
- Adjusted PlaylistRepository to load sound extractions when retrieving playlist sounds.
- Added tests for new fields in extraction and sound endpoints, ensuring proper response structure.
- Created new test file endpoints for sound downloads and thumbnail retrievals, including success and error cases.
- Refactored various test cases for consistency and clarity, ensuring proper mocking and assertions.
This commit is contained in:
JSC
2025-08-03 20:54:14 +02:00
parent 77446cb5a8
commit b4f0f54516
20 changed files with 780 additions and 73 deletions

View File

@@ -49,7 +49,8 @@ class TestCreditService:
mock_repo.get_by_id.return_value = sample_user
result = await credit_service.check_credits(
1, CreditActionType.VLC_PLAY_SOUND,
1,
CreditActionType.VLC_PLAY_SOUND,
)
assert result is True
@@ -75,7 +76,8 @@ class TestCreditService:
mock_repo.get_by_id.return_value = poor_user
result = await credit_service.check_credits(
1, CreditActionType.VLC_PLAY_SOUND,
1,
CreditActionType.VLC_PLAY_SOUND,
)
assert result is False
@@ -92,7 +94,8 @@ class TestCreditService:
mock_repo.get_by_id.return_value = None
result = await credit_service.check_credits(
999, CreditActionType.VLC_PLAY_SOUND,
999,
CreditActionType.VLC_PLAY_SOUND,
)
assert result is False
@@ -100,7 +103,9 @@ class TestCreditService:
@pytest.mark.asyncio
async def test_validate_and_reserve_credits_success(
self, credit_service, sample_user,
self,
credit_service,
sample_user,
) -> None:
"""Test successful credit validation and reservation."""
mock_session = credit_service.db_session_factory()
@@ -122,7 +127,8 @@ class TestCreditService:
@pytest.mark.asyncio
async def test_validate_and_reserve_credits_insufficient(
self, credit_service,
self,
credit_service,
) -> None:
"""Test credit validation with insufficient credits."""
mock_session = credit_service.db_session_factory()
@@ -152,7 +158,8 @@ class TestCreditService:
@pytest.mark.asyncio
async def test_validate_and_reserve_credits_user_not_found(
self, credit_service,
self,
credit_service,
) -> None:
"""Test credit validation when user is not found."""
mock_session = credit_service.db_session_factory()
@@ -225,7 +232,9 @@ class TestCreditService:
@pytest.mark.asyncio
async def test_deduct_credits_failed_action_requires_success(
self, credit_service, sample_user,
self,
credit_service,
sample_user,
) -> None:
"""Test credit deduction when action failed but requires success."""
mock_session = credit_service.db_session_factory()