Ejemplo n.º 1
0
    def test_get_queryset(self):
        aff_org_inline = AffiliatedOrganizationInline(Organization, self.site)
        request = self.factory.get('/fake-url/')
        request.user = self.admin

        qs = aff_org_inline.get_queryset(request)
        self.assertQuerysetEqual(qs, [repr(self.editable_org)])
Ejemplo n.º 2
0
    def test_readonly_fields(self):
        aff_org_inline = AffiliatedOrganizationInline(Organization, self.site)
        request = self.factory.get('/fake-url/')
        request.user = self.admin

        self.assertEquals(('data_source', 'origin_id', 'id'), aff_org_inline.get_readonly_fields(request))
        self.assertEquals(('data_source', 'origin_id', 'id'),
                          aff_org_inline.get_readonly_fields(request, obj=self.editable_org))
Ejemplo n.º 3
0
    def test_has_delete_permission(self):
        aff_org_inline = AffiliatedOrganizationInline(Organization, self.site)
        request = self.factory.get('/fake-url/')
        request.user = self.normal_admin

        has_perm = aff_org_inline.has_delete_permission(request)
        self.assertFalse(has_perm)

        clear_user_perm_cache(self.normal_admin)
        perm = Permission.objects.get(codename='delete_affiliated_organization')
        self.normal_admin.user_permissions.add(perm)

        has_perm = aff_org_inline.has_delete_permission(request)
        self.assertTrue(has_perm)