refactor: Improve code readability by formatting query parameters in user endpoints and enhancing error handling in sound playback
This commit is contained in:
@@ -204,7 +204,8 @@ class TestAdminUserEndpoints:
|
||||
) -> None:
|
||||
"""Test listing users as non-admin user."""
|
||||
with patch(
|
||||
"app.core.dependencies.get_current_active_user", return_value=regular_user,
|
||||
"app.core.dependencies.get_current_active_user",
|
||||
return_value=regular_user,
|
||||
):
|
||||
response = await client.get("/api/v1/admin/users/")
|
||||
|
||||
@@ -296,7 +297,8 @@ class TestAdminUserEndpoints:
|
||||
) as mock_get_by_id,
|
||||
patch("app.repositories.user.UserRepository.update") as mock_update,
|
||||
patch(
|
||||
"app.repositories.plan.PlanRepository.get_by_id", return_value=test_plan,
|
||||
"app.repositories.plan.PlanRepository.get_by_id",
|
||||
return_value=test_plan,
|
||||
),
|
||||
):
|
||||
mock_user = type(
|
||||
|
||||
@@ -609,7 +609,8 @@ class TestAuthEndpoints:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_update_profile_unauthenticated(
|
||||
self, test_client: AsyncClient,
|
||||
self,
|
||||
test_client: AsyncClient,
|
||||
) -> None:
|
||||
"""Test update profile without authentication."""
|
||||
response = await test_client.patch(
|
||||
@@ -645,7 +646,8 @@ class TestAuthEndpoints:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_change_password_unauthenticated(
|
||||
self, test_client: AsyncClient,
|
||||
self,
|
||||
test_client: AsyncClient,
|
||||
) -> None:
|
||||
"""Test change password without authentication."""
|
||||
response = await test_client.post(
|
||||
@@ -716,7 +718,8 @@ class TestAuthEndpoints:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_user_providers_unauthenticated(
|
||||
self, test_client: AsyncClient,
|
||||
self,
|
||||
test_client: AsyncClient,
|
||||
) -> None:
|
||||
"""Test get user OAuth providers without authentication."""
|
||||
response = await test_client.get("/api/v1/auth/user-providers")
|
||||
|
||||
@@ -540,15 +540,19 @@ class TestPlaylistRepository:
|
||||
|
||||
# Add first two sounds sequentially (positions 0, 1)
|
||||
await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound_ids[0],
|
||||
playlist_id,
|
||||
sound_ids[0],
|
||||
) # position 0
|
||||
await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound_ids[1],
|
||||
playlist_id,
|
||||
sound_ids[1],
|
||||
) # position 1
|
||||
|
||||
# Now insert third sound at position 1 - should shift existing sound at position 1 to position 2
|
||||
await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound_ids[2], position=1,
|
||||
playlist_id,
|
||||
sound_ids[2],
|
||||
position=1,
|
||||
)
|
||||
|
||||
# Verify the final positions
|
||||
@@ -630,15 +634,19 @@ class TestPlaylistRepository:
|
||||
|
||||
# Add first two sounds sequentially (positions 0, 1)
|
||||
await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound_ids[0],
|
||||
playlist_id,
|
||||
sound_ids[0],
|
||||
) # position 0
|
||||
await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound_ids[1],
|
||||
playlist_id,
|
||||
sound_ids[1],
|
||||
) # position 1
|
||||
|
||||
# Now insert third sound at position 0 - should shift existing sounds to positions 1, 2
|
||||
await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound_ids[2], position=0,
|
||||
playlist_id,
|
||||
sound_ids[2],
|
||||
position=0,
|
||||
)
|
||||
|
||||
# Verify the final positions
|
||||
|
||||
@@ -63,7 +63,8 @@ class TestSchedulerService:
|
||||
}
|
||||
|
||||
with patch.object(
|
||||
scheduler_service.credit_service, "recharge_all_users_credits",
|
||||
scheduler_service.credit_service,
|
||||
"recharge_all_users_credits",
|
||||
) as mock_recharge:
|
||||
mock_recharge.return_value = mock_stats
|
||||
|
||||
@@ -75,7 +76,8 @@ class TestSchedulerService:
|
||||
async def test_daily_credit_recharge_failure(self, scheduler_service) -> None:
|
||||
"""Test daily credit recharge task with failure."""
|
||||
with patch.object(
|
||||
scheduler_service.credit_service, "recharge_all_users_credits",
|
||||
scheduler_service.credit_service,
|
||||
"recharge_all_users_credits",
|
||||
) as mock_recharge:
|
||||
mock_recharge.side_effect = Exception("Database error")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user