Refactor user endpoint tests to include pagination and response structure validation
- Updated tests for listing users to validate pagination and response format. - Changed mock return values to include total count and pagination details. - Refactored user creation mocks for clarity and consistency. - Enhanced assertions to check for presence of pagination fields in responses. - Adjusted test cases for user retrieval and updates to ensure proper handling of user data. - Improved readability by restructuring mock definitions and assertions across various test files.
This commit is contained in:
@@ -141,7 +141,7 @@ class SoundRepository(BaseRepository[Sound]):
|
||||
sort_order: SortOrder = SortOrder.ASC,
|
||||
limit: int | None = None,
|
||||
offset: int = 0,
|
||||
favorites_only: bool = False,
|
||||
favorites_only: bool = False, # noqa: FBT001, FBT002
|
||||
user_id: int | None = None,
|
||||
) -> list[Sound]:
|
||||
"""Search and sort sounds with optional filtering."""
|
||||
@@ -189,7 +189,8 @@ class SoundRepository(BaseRepository[Sound]):
|
||||
logger.exception(
|
||||
(
|
||||
"Failed to search and sort sounds: "
|
||||
"query=%s, types=%s, sort_by=%s, sort_order=%s, favorites_only=%s, user_id=%s"
|
||||
"query=%s, types=%s, sort_by=%s, sort_order=%s, favorites_only=%s, "
|
||||
"user_id=%s"
|
||||
),
|
||||
search_query,
|
||||
sound_types,
|
||||
@@ -288,8 +289,7 @@ class SoundRepository(BaseRepository[Sound]):
|
||||
|
||||
# Group by sound and order by play count descending
|
||||
statement = (
|
||||
statement
|
||||
.group_by(
|
||||
statement.group_by(
|
||||
Sound.id,
|
||||
Sound.name,
|
||||
Sound.type,
|
||||
|
||||
Reference in New Issue
Block a user