Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
steering
Commits
91ae2f85
Verified
Commit
91ae2f85
authored
3 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
refactor: move fixtures -> test_playlists
parent
7c577987
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
conftest.py
+0
-35
0 additions, 35 deletions
conftest.py
program/tests/test_playlists.py
+43
-1
43 additions, 1 deletion
program/tests/test_playlists.py
with
43 additions
and
36 deletions
conftest.py
+
0
−
35
View file @
91ae2f85
...
...
@@ -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
()
This diff is collapsed.
Click to expand it.
program/tests/test_playlists.py
+
43
−
1
View file @
91ae2f85
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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment