prod: UI Optimisée mise en production
- Documentation archivée et réorganisée - Backend: Ajout tests, migrations, library service, rate limiting - Frontend: Suppression Flutter, focus sur interface web HTML/JS - Tailwind CSS ajouté pour le style - Améliorations UX et corrections bugs Generated with [Claude Code](https://claude.com/claude-code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
"""Test data models."""
|
||||
import pytest
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
|
||||
class TestUserModel:
|
||||
"""Tests for User model."""
|
||||
|
||||
async def test_create_user(self, db_session: AsyncSession):
|
||||
"""Test creating a user."""
|
||||
from app.models.user import User
|
||||
from app.core.security import hash_password
|
||||
|
||||
user = User(
|
||||
email="test@example.com",
|
||||
username="testuser",
|
||||
password_hash=hash_password("password123"),
|
||||
)
|
||||
|
||||
db_session.add(user)
|
||||
await db_session.commit()
|
||||
await db_session.refresh(user)
|
||||
|
||||
assert user.id is not None
|
||||
assert user.email == "test@example.com"
|
||||
assert user.username == "testuser"
|
||||
assert user.password_hash != "password123" # Should be hashed
|
||||
|
||||
async def test_user_repr(self, db_session: AsyncSession):
|
||||
"""Test user __repr__ method."""
|
||||
from app.models.user import User
|
||||
from app.core.security import hash_password
|
||||
|
||||
user = User(
|
||||
email="repr@example.com",
|
||||
username="repruser",
|
||||
password_hash=hash_password("password123"),
|
||||
)
|
||||
|
||||
db_session.add(user)
|
||||
await db_session.commit()
|
||||
|
||||
repr_str = repr(user)
|
||||
assert "repr@example.com" in repr_str
|
||||
|
||||
|
||||
class TestTrackModel:
|
||||
"""Tests for Track model."""
|
||||
|
||||
async def test_create_track(self, db_session: AsyncSession):
|
||||
"""Test creating a track."""
|
||||
from app.models.track import Track
|
||||
from app.models.artist import Artist
|
||||
|
||||
# Create artist first
|
||||
artist = Artist(name="Test Artist")
|
||||
db_session.add(artist)
|
||||
await db_session.commit()
|
||||
await db_session.refresh(artist)
|
||||
|
||||
# Create track
|
||||
track = Track(
|
||||
title="Test Track",
|
||||
duration=180,
|
||||
artist_id=artist.id,
|
||||
youtube_id="test_yt_id",
|
||||
)
|
||||
|
||||
db_session.add(track)
|
||||
await db_session.commit()
|
||||
await db_session.refresh(track)
|
||||
|
||||
assert track.id is not None
|
||||
assert track.title == "Test Track"
|
||||
assert track.duration == 180
|
||||
assert track.artist_id == artist.id
|
||||
|
||||
|
||||
class TestPlaylistModel:
|
||||
"""Tests for Playlist model."""
|
||||
|
||||
async def test_create_playlist(self, db_session: AsyncSession):
|
||||
"""Test creating a playlist."""
|
||||
from app.models.playlist import Playlist
|
||||
from app.models.user import User
|
||||
from app.core.security import hash_password
|
||||
|
||||
# Create user
|
||||
user = User(
|
||||
email="playlist@example.com",
|
||||
username="playlistuser",
|
||||
password_hash=hash_password("password123"),
|
||||
)
|
||||
db_session.add(user)
|
||||
await db_session.commit()
|
||||
await db_session.refresh(user)
|
||||
|
||||
# Create playlist
|
||||
playlist = Playlist(
|
||||
user_id=user.id,
|
||||
name="Test Playlist",
|
||||
description="Test description",
|
||||
)
|
||||
|
||||
db_session.add(playlist)
|
||||
await db_session.commit()
|
||||
await db_session.refresh(playlist)
|
||||
|
||||
assert playlist.id is not None
|
||||
assert playlist.name == "Test Playlist"
|
||||
assert playlist.user_id == user.id
|
||||
Reference in New Issue
Block a user