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

refactor: move fixtures -> test_playlists

parent 7c577987
No related branches found
No related tags found
No related merge requests found
......@@ -130,17 +130,6 @@ def common_user2() -> User:
return CommonUserFactory()
@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"""
......@@ -159,15 +148,6 @@ def common_api_client2(api_client, common_user2) -> 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)
......@@ -233,16 +213,6 @@ 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"""
......@@ -420,11 +390,6 @@ def playlist(show) -> Playlist:
return PlaylistFactory(show=show)
@pytest.fixture
def playlist_entry(playlist) -> PlaylistEntry:
return PlaylistEntryFactory(playlist=playlist)
@pytest.fixture
def license_() -> License:
return LicenseFactory()
import random
import pytest
from rest_framework.test import APIClient
from conftest import assert_data
from program.tests.factories import PlaylistFactory
from django.contrib.auth.models import Permission, User
from program.models import PlaylistEntry, Show
from program.tests.factories import (
PlaylistEntryFactory,
PlaylistFactory,
UserWithPermissionsFactory,
)
pytestmark = pytest.mark.django_db
......@@ -34,6 +41,41 @@ def playlist_entries_data(show, file_id, entries=1):
]
@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 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 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 playlist_entry(playlist) -> PlaylistEntry:
return PlaylistEntryFactory(playlist=playlist)
def test_create_playlist(
user_with_playlist_perms, api_client_playlist_perms, owned_show_playlist_perms
):
......
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