diff --git a/src/viralhostrange/viralhostrangedb/tests/test_templatetags.py b/src/viralhostrange/viralhostrangedb/tests/test_templatetags.py index e0fc3b69da46a1197b5126f53f6235eff425f20e..723594245ca512d8b4aa9a383e4fb557fb80d0ba 100644 --- a/src/viralhostrange/viralhostrangedb/tests/test_templatetags.py +++ b/src/viralhostrange/viralhostrangedb/tests/test_templatetags.py @@ -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))