Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hub
ViralHostRangeDB
Commits
b05cfff2
Commit
b05cfff2
authored
Feb 03, 2022
by
Bryan BRANCOTTE
Browse files
testing is_editor_or_owner_of_ds
parent
40820bbe
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/viralhostrange/viralhostrangedb/tests/test_templatetags.py
View file @
b05cfff2
...
...
@@ -4,7 +4,7 @@ from django.test import TestCase, override_settings
from
django.utils
import
timezone
from
viralhostrangedb
import
models
,
business_process
from
viralhostrangedb.templatetags.viralhostrange_tags
import
can_edit
,
can_see
,
can_delete
from
viralhostrangedb.templatetags.viralhostrange_tags
import
can_edit
,
can_see
,
can_delete
,
is_editor_or_owner_of_ds
class
TemplateTagsTests
(
TestCase
):
...
...
@@ -84,6 +84,21 @@ class TemplateTagsTests(TestCase):
business_process
.
set_curator
(
self
.
user
,
True
)
self
.
assertTrue
(
can_edit
(
self
.
user
,
self
.
d_toto
))
@
override_settings
(
DEBUG
=
False
)
def
test_is_editor_or_owner_of_ds
(
self
):
self
.
assertFalse
(
is_editor_or_owner_of_ds
(
self
.
user
,
self
.
d_toto
))
self
.
assertTrue
(
is_editor_or_owner_of_ds
(
self
.
toto
,
self
.
d_toto
))
self
.
assertTrue
(
is_editor_or_owner_of_ds
(
self
.
titi
,
self
.
d_toto_grant_titi
))
business_process
.
set_curator
(
self
.
titi
,
True
)
self
.
assertTrue
(
is_editor_or_owner_of_ds
(
self
.
titi
,
self
.
d_toto_grant_titi
),
"should still be allowed"
)
self
.
assertFalse
(
is_editor_or_owner_of_ds
(
self
.
user
,
self
.
d_toto_grant_titi
))
self
.
assertFalse
(
is_editor_or_owner_of_ds
(
self
.
user
,
self
.
d_toto_grant_titi
.
pk
))
business_process
.
set_curator
(
self
.
user
,
True
)
self
.
assertFalse
(
is_editor_or_owner_of_ds
(
self
.
user
,
self
.
d_toto_grant_titi
),
"still not allowed"
)
self
.
assertFalse
(
is_editor_or_owner_of_ds
(
self
.
user
,
self
.
d_toto_grant_titi
.
pk
),
"still not allowed"
)
@
override_settings
(
DEBUG
=
False
)
def
test_can_delete
(
self
):
self
.
assertFalse
(
can_delete
(
self
.
user
,
self
.
d_toto
))
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment