Refactor sound and extraction services to include user and timestamp fields
- 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:
@@ -28,7 +28,8 @@ class TestRequiresCreditsDecorator:
|
||||
|
||||
@pytest.fixture
|
||||
def credit_service_factory(
|
||||
self, mock_credit_service: AsyncMock,
|
||||
self,
|
||||
mock_credit_service: AsyncMock,
|
||||
) -> Callable[[], AsyncMock]:
|
||||
"""Create a credit service factory."""
|
||||
return lambda: mock_credit_service
|
||||
@@ -98,7 +99,9 @@ class TestRequiresCreditsDecorator:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_decorator_failed_action(
|
||||
self, credit_service_factory, mock_credit_service,
|
||||
self,
|
||||
credit_service_factory,
|
||||
mock_credit_service,
|
||||
) -> None:
|
||||
"""Test decorator with failed action."""
|
||||
|
||||
@@ -122,7 +125,9 @@ class TestRequiresCreditsDecorator:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_decorator_exception_in_action(
|
||||
self, credit_service_factory, mock_credit_service,
|
||||
self,
|
||||
credit_service_factory,
|
||||
mock_credit_service,
|
||||
) -> None:
|
||||
"""Test decorator when action raises exception."""
|
||||
|
||||
@@ -147,7 +152,9 @@ class TestRequiresCreditsDecorator:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_decorator_insufficient_credits(
|
||||
self, credit_service_factory, mock_credit_service,
|
||||
self,
|
||||
credit_service_factory,
|
||||
mock_credit_service,
|
||||
) -> None:
|
||||
"""Test decorator with insufficient credits."""
|
||||
mock_credit_service.validate_and_reserve_credits.side_effect = (
|
||||
@@ -170,7 +177,9 @@ class TestRequiresCreditsDecorator:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_decorator_user_id_in_args(
|
||||
self, credit_service_factory, mock_credit_service,
|
||||
self,
|
||||
credit_service_factory,
|
||||
mock_credit_service,
|
||||
) -> None:
|
||||
"""Test decorator extracting user_id from positional args."""
|
||||
|
||||
@@ -218,14 +227,17 @@ class TestValidateCreditsOnlyDecorator:
|
||||
|
||||
@pytest.fixture
|
||||
def credit_service_factory(
|
||||
self, mock_credit_service: AsyncMock,
|
||||
self,
|
||||
mock_credit_service: AsyncMock,
|
||||
) -> Callable[[], AsyncMock]:
|
||||
"""Create a credit service factory."""
|
||||
return lambda: mock_credit_service
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_validate_only_decorator(
|
||||
self, credit_service_factory, mock_credit_service,
|
||||
self,
|
||||
credit_service_factory,
|
||||
mock_credit_service,
|
||||
) -> None:
|
||||
"""Test validate_credits_only decorator."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user