def test_user_cant_manage(self): user = UserFactory() journal = JournalFactory() is_granted = user.has_perm('authorization.manage_authorizations', journal) self.assertEqual(is_granted, False) journal.members.add(user) journal.save() is_granted = user.has_perm('authorization.manage_authorizations', journal) self.assertEqual(is_granted, False)
def test_user_can_manage(self): user = UserFactory() journal = JournalFactory() journal.members.add(user) journal.save() ct = ContentType.objects.get(app_label="erudit", model="journal") Authorization.objects.create( content_type=ct, user=user, object_id=journal.id, authorization_codename=AC.can_manage_authorizations.codename) is_granted = user.has_perm('authorization.manage_authorizations', journal) self.assertEqual(is_granted, True)
def test_staff_can_manage(self): user = UserFactory(is_staff=True) journal = JournalFactory() is_granted = user.has_perm('authorization.manage_authorizations', journal) self.assertEqual(is_granted, True)