refactor: Rename global current playlist methods for clarity and consistency

This commit is contained in:
JSC
2025-08-01 17:12:56 +02:00
parent c0f51b2e23
commit 0575d12b0e
6 changed files with 33 additions and 104 deletions

View File

@@ -222,28 +222,11 @@ class TestPlaylistRepository:
test_session: AsyncSession,
ensure_plans: Any,
) -> None:
"""Test getting current playlist when none is set."""
# Create test user within this test
user = User(
email="test2@example.com",
name="Test User 2",
password_hash=PasswordUtils.hash_password("password123"),
role="user",
is_active=True,
plan_id=ensure_plans[0].id,
credits=100,
)
test_session.add(user)
await test_session.commit()
await test_session.refresh(user)
"""Test getting current playlist when none is set globally."""
# Test the repository method - should return None when no current playlist is set globally
playlist = await playlist_repository.get_current_playlist()
# Extract user ID immediately after refresh
user_id = user.id
# Test the repository method - should return None when no current playlist
playlist = await playlist_repository.get_current_playlist(user_id)
# Should return None since no user playlist is marked as current
# Should return None since no playlist is marked as current globally
assert playlist is None
@pytest.mark.asyncio

View File

@@ -464,7 +464,7 @@ class TestPlaylistService:
# Verify main playlist is now fallback current (main playlist doesn't have is_current=True)
# The service returns main playlist when no current is set
current = await playlist_service.get_current_playlist(user_id)
current = await playlist_service.get_current_playlist()
assert current.is_main is True
@pytest.mark.asyncio
@@ -754,7 +754,7 @@ class TestPlaylistService:
# Set test_playlist as current
updated_playlist = await playlist_service.set_current_playlist(
test_playlist_id, user_id,
test_playlist_id,
)
assert updated_playlist.is_current is True
@@ -804,10 +804,10 @@ class TestPlaylistService:
assert current_playlist.is_current is True
# Unset current playlist
await playlist_service.unset_current_playlist(user_id)
await playlist_service.unset_current_playlist()
# Verify get_current_playlist returns main playlist as fallback
current = await playlist_service.get_current_playlist(user_id)
current = await playlist_service.get_current_playlist()
assert current.id == main_playlist_id
assert current.is_main is True