Commit b05cfff2 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

testing is_editor_or_owner_of_ds

parent 40820bbe
......@@ -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))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment