- 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.
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from typing import TYPE_CHECKING
|
|
|
|
from sqlmodel import Field, Relationship, UniqueConstraint
|
|
|
|
from app.models.base import BaseModel
|
|
|
|
if TYPE_CHECKING:
|
|
from app.models.playlist import Playlist
|
|
from app.models.sound import Sound
|
|
|
|
|
|
class PlaylistSound(BaseModel, table=True):
|
|
"""Database model for a sound in a playlist."""
|
|
|
|
__tablename__ = "playlist_sound" # pyright: ignore[reportAssignmentType]
|
|
|
|
playlist_id: int = Field(foreign_key="playlist.id", nullable=False)
|
|
sound_id: int = Field(foreign_key="sound.id", nullable=False)
|
|
position: int = Field(default=0, ge=0, nullable=False)
|
|
|
|
# constraints
|
|
__table_args__ = (
|
|
UniqueConstraint(
|
|
"playlist_id",
|
|
"sound_id",
|
|
name="uq_playlist_sound_playlist_sound",
|
|
),
|
|
UniqueConstraint(
|
|
"playlist_id",
|
|
"position",
|
|
name="uq_playlist_sound_playlist_position",
|
|
),
|
|
)
|
|
|
|
# relationships
|
|
playlist: "Playlist" = Relationship(back_populates="playlist_sounds")
|
|
sound: "Sound" = Relationship(back_populates="playlist_sounds")
|