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')
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')
def assertGroupHasPermission(self, group, perm_name): permission = get_permission_by_name(perm_name) self.assertTrue(group.permissions.filter(pk=permission.pk).exists())
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)