Skip to content
Snippets Groups Projects
Verified Commit 9496ad31 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

test: add fixtures for user, api_client playlist perms, owned show, playlist & playlist_entry

parent cb251108
No related branches found
No related tags found
1 merge request!59Add playlists
......@@ -15,6 +15,7 @@ from program.models import (
LinkType,
MusicFocus,
Playlist,
PlaylistEntry,
Profile,
RadioSettings,
RRule,
......@@ -35,6 +36,7 @@ from program.tests.factories import (
LinkTypeFactory,
MusicFocusFactory,
OwnerFactory,
PlaylistEntryFactory,
PlaylistFactory,
ProfileFactory,
RadioSettingsFactory,
......@@ -149,6 +151,17 @@ def user_with_note_perms() -> User:
return UserWithPermissionsFactory.create(user_permissions=permissions)
@pytest.fixture
def user_with_playlist_perms() -> User:
"""User with add_playlist, change_playlist, delete_playlist permission"""
permissions = Permission.objects.filter(
codename__in=["add_playlist", "change_playlist", "delete_playlist"]
)
return UserWithPermissionsFactory.create(user_permissions=permissions)
@pytest.fixture
def common_api_client1(api_client, common_user1) -> APIClient:
"""Authenticated common user 1 API client"""
......@@ -176,6 +189,15 @@ def api_client_note_perms(api_client, user_with_note_perms) -> APIClient:
api_client.force_authenticate()
@pytest.fixture
def api_client_playlist_perms(api_client, user_with_playlist_perms) -> APIClient:
"""Authenticated API client for user with {add,change,delete}_playlist permissions"""
api_client.force_authenticate(user_with_playlist_perms)
yield api_client
api_client.force_authenticate()
@pytest.fixture
def once_rrule() -> RRule:
return RRuleFactory(freq=0)
......@@ -221,6 +243,16 @@ def owned_show(common_user1, show) -> Show:
return show
@pytest.fixture
def owned_show_playlist_perms(user_with_playlist_perms, show) -> Show:
"""Show owned by user with playlist permissions"""
show.owners.set([user_with_playlist_perms])
show.save()
return show
@pytest.fixture
def owned_show_once_timeslot(common_user1, show, once_schedule) -> TimeSlot:
"""Timeslot of a once schedule for a show owned by a common user"""
......@@ -308,3 +340,13 @@ def owner() -> User:
@pytest.fixture
def default_playlist(show) -> Playlist:
return PlaylistFactory(description="default playlist", show=show)
@pytest.fixture
def playlist(show) -> Playlist:
return PlaylistFactory(show=show)
@pytest.fixture
def playlist_entry(playlist) -> PlaylistEntry:
return PlaylistEntryFactory(playlist=playlist)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment