def test_get_queryset(self): sub_org_inline = AddSubOrganizationInline(Organization, self.site) request = self.factory.get('/fake-url/') request.user = self.admin qs = sub_org_inline.get_queryset(request) self.assertQuerysetEqual(qs, [])
def test_readonly_fields(self): sub_org_inline = AddSubOrganizationInline(Organization, self.site) request = self.factory.get('/fake-url/') request.user = self.admin self.assertEquals(('id',), sub_org_inline.get_readonly_fields(request)) self.assertEquals(('id',), sub_org_inline.get_readonly_fields(request, obj=self.editable_org))
def test_has_delete_permission(self): sub_org_inline = AddSubOrganizationInline(Organization, self.site) request = self.factory.get('/fake-url/') request.user = self.normal_admin has_perm = sub_org_inline.has_delete_permission(request) self.assertFalse(has_perm) clear_user_perm_cache(self.normal_admin) perm = Permission.objects.get(codename='delete_organization') self.normal_admin.user_permissions.add(perm) has_perm = sub_org_inline.has_delete_permission(request) self.assertFalse(has_perm)