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
af2bc95c
Verified
Commit
af2bc95c
authored
11 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
test: add fixtures for user with note permissios, owned show/timeslot and API client
parent
743dbeaf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
conftest.py
+41
-5
41 additions, 5 deletions
conftest.py
with
41 additions
and
5 deletions
conftest.py
+
41
−
5
View file @
af2bc95c
...
...
@@ -3,7 +3,7 @@ from datetime import datetime, timedelta
import
pytest
from
rest_framework.test
import
APIClient
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
Permission
,
User
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
program.models
import
(
FundingCategory
,
...
...
@@ -27,6 +27,7 @@ from program.tests.factories import (
ShowFactory
,
TimeslotFactory
,
TypeFactory
,
UserWithPermissionsFactory
,
)
...
...
@@ -97,6 +98,17 @@ def common_user2() -> User:
return
CommonUserFactory
()
@pytest.fixture
def
user_with_note_perms
()
->
User
:
"""
User with add_note, change_note, delete_note permissions
"""
permissions
=
Permission
.
objects
.
filter
(
codename__in
=
[
"
add_note
"
,
"
change_note
"
,
"
delete_note
"
]
)
return
UserWithPermissionsFactory
.
create
(
user_permissions
=
permissions
)
@pytest.fixture
def
common_api_client1
(
api_client
,
common_user1
)
->
APIClient
:
"""
Authenticated common user 1 API client
"""
...
...
@@ -115,6 +127,15 @@ def common_api_client2(api_client, common_user2) -> APIClient:
api_client
.
force_authenticate
()
@pytest.fixture
def
api_client_note_perms
(
api_client
,
user_with_note_perms
)
->
APIClient
:
"""
Authenticated API client for user with add_note, change_note, delete_note permissions
"""
api_client
.
force_authenticate
(
user_with_note_perms
)
yield
api_client
api_client
.
force_authenticate
()
@pytest.fixture
def
once_rrule
()
->
RRule
:
return
RRuleFactory
(
freq
=
0
)
...
...
@@ -126,8 +147,8 @@ def show() -> Show:
@pytest.fixture
def
owned_show
(
common_user1
)
:
show
=
ShowFactory
()
def
owned_show
(
common_user1
,
show
)
->
Show
:
"""
Show owned by a common user
"""
show
.
owners
.
set
([
common_user1
])
show
.
save
()
...
...
@@ -137,12 +158,27 @@ def owned_show(common_user1):
@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
"""
show
.
owners
.
set
([
common_user1
])
show
.
save
()
timeslot
=
TimeslotFactory
(
schedule
=
once_schedule
)
return
TimeslotFactory
(
schedule
=
once_schedule
)
@pytest.fixture
def
owned_show_once_timeslot_perms
(
user_with_note_perms
,
show
,
once_schedule
)
->
TimeSlot
:
"""
Timeslot of a once schedule for a show owned by a user with add_note permission
"""
show
.
owners
.
set
([
user_with_note_perms
])
show
.
save
()
return
TimeslotFactory
(
schedule
=
once_schedule
)
return
timeslot
@pytest.fixture
def
show_once_timeslot
(
show
,
once_schedule
)
->
TimeSlot
:
return
TimeslotFactory
(
schedule
=
once_schedule
)
@pytest.fixture
...
...
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