/usr/lib/python2.7/dist-packages/guardian/testapp/tests/custompkmodel_test.py is in python-django-guardian 1.2.4+git20141127-0.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | from __future__ import unicode_literals
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase
from guardian.compat import get_user_model
from guardian.shortcuts import assign_perm, remove_perm
class CustomPKModelTest(TestCase):
"""
Tests agains custom model with primary key other than *standard*
``id`` integer field.
"""
def setUp(self):
self.user = get_user_model().objects.create(username='joe')
self.ctype = ContentType.objects.create(name='foo', model='bar',
app_label='fake-for-guardian-tests')
def test_assign_perm(self):
assign_perm('contenttypes.change_contenttype', self.user, self.ctype)
self.assertTrue(self.user.has_perm('contenttypes.change_contenttype',
self.ctype))
def test_remove_perm(self):
assign_perm('contenttypes.change_contenttype', self.user, self.ctype)
self.assertTrue(self.user.has_perm('contenttypes.change_contenttype',
self.ctype))
remove_perm('contenttypes.change_contenttype', self.user, self.ctype)
self.assertFalse(self.user.has_perm('contenttypes.change_contenttype',
self.ctype))
|