Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale_OLD
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Service Desk
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
jovuit
funkwhale_OLD
Commits
1f2e14b2
Verified
Commit
1f2e14b2
authored
7 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Use anonymous_user fixture in other tests
parent
122c3907
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/tests/common/test_permissions.py
+6
-5
6 additions, 5 deletions
api/tests/common/test_permissions.py
with
6 additions
and
5 deletions
api/tests/common/test_permissions.py
+
6
−
5
View file @
1f2e14b2
...
...
@@ -2,7 +2,6 @@ import pytest
from
rest_framework.views
import
APIView
from
django.contrib.auth.models
import
AnonymousUser
from
django.http
import
Http404
from
funkwhale_api.common
import
permissions
...
...
@@ -19,24 +18,26 @@ def test_owner_permission_owner_field_ok(nodb_factories, api_request):
assert
check
is
True
def
test_owner_permission_owner_field_not_ok
(
nodb_factories
,
api_request
):
def
test_owner_permission_owner_field_not_ok
(
anonymous_user
,
nodb_factories
,
api_request
):
playlist
=
nodb_factories
[
'
playlists.Playlist
'
]()
view
=
APIView
.
as_view
()
permission
=
permissions
.
OwnerPermission
()
request
=
api_request
.
get
(
'
/
'
)
setattr
(
request
,
'
user
'
,
A
nonymous
U
ser
()
)
setattr
(
request
,
'
user
'
,
a
nonymous
_u
ser
)
with
pytest
.
raises
(
Http404
):
permission
.
has_object_permission
(
request
,
view
,
playlist
)
def
test_owner_permission_read_only
(
nodb_factories
,
api_request
):
def
test_owner_permission_read_only
(
anonymous_user
,
nodb_factories
,
api_request
):
playlist
=
nodb_factories
[
'
playlists.Playlist
'
]()
view
=
APIView
.
as_view
()
setattr
(
view
,
'
owner_checks
'
,
[
'
write
'
])
permission
=
permissions
.
OwnerPermission
()
request
=
api_request
.
get
(
'
/
'
)
setattr
(
request
,
'
user
'
,
A
nonymous
U
ser
()
)
setattr
(
request
,
'
user
'
,
a
nonymous
_u
ser
)
check
=
permission
.
has_object_permission
(
request
,
view
,
playlist
)
assert
check
is
True
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