Esempio n. 1
0
 def test_extras_not_removed(self):
     # If a group already has some other permissions, running bootstrap
     # will leave them alone
     group = Group.objects.create(name='role')
     group.permissions.add(get_permission_by_name('shipments.existing_permission'))
     bootstrap_permissions()
     self.assertGroupHasPermission(group, 'shipments.do_something')
     self.assertGroupHasPermission(group, 'shipments.existing_permission')
Esempio n. 2
0
 def test_extras_not_removed(self):
     # If a group already has some other permissions, running bootstrap
     # will leave them alone
     group = Group.objects.create(name='role')
     group.permissions.add(
         get_permission_by_name('shipments.existing_permission'))
     bootstrap_permissions()
     self.assertGroupHasPermission(group, 'shipments.do_something')
     self.assertGroupHasPermission(group, 'shipments.existing_permission')
Esempio n. 3
0
 def assertGroupHasPermission(self, group, perm_name):
     permission = get_permission_by_name(perm_name)
     self.assertTrue(group.permissions.filter(pk=permission.pk).exists())
Esempio n. 4
0
 def test_simple_case(self):
     bootstrap_permissions()
     group = Group.objects.get(name='role')
     self.assertGroupHasPermission(group, 'shipments.do_something')
     perm = get_permission_by_name('shipments.do_something')
     self.assertEqual('Can do something', perm.name)
Esempio n. 5
0
 def assertGroupHasPermission(self, group, perm_name):
     permission = get_permission_by_name(perm_name)
     self.assertTrue(group.permissions.filter(pk=permission.pk).exists())
Esempio n. 6
0
 def test_simple_case(self):
     bootstrap_permissions()
     group = Group.objects.get(name='role')
     self.assertGroupHasPermission(group, 'shipments.do_something')
     perm = get_permission_by_name('shipments.do_something')
     self.assertEqual('Can do something', perm.name)