Example #1
0
    def test_permission_manager(self):
        """
        Test page permission manager working on a subpage
        """
        page_b = create_page("page_b",
                             "nav_playground.html",
                             "en",
                             created_by=self.user_super)
        assign_user_to_page(page_b,
                            self.user_normal,
                            can_view=True,
                            can_change=True)
        cached_permissions = get_permission_cache(self.user_normal,
                                                  "change_page")
        self.assertIsNone(cached_permissions)

        live_permissions = get_change_id_list(self.user_normal,
                                              Site.objects.get_current())
        cached_permissions_permissions = get_permission_cache(
            self.user_normal, "change_page")
        self.assertEqual(live_permissions, [page_b.id])
        self.assertEqual(cached_permissions_permissions, live_permissions)

        self.home_page.save()
        cached_permissions = get_permission_cache(self.user_normal,
                                                  "change_page")
        self.assertIsNone(cached_permissions)
Example #2
0
    def test_permission_manager(self):
        """
        Test page permission manager working on a subpage
        """
        page_b = create_page("page_b", "nav_playground.html", "en",
                             created_by=self.user_super)
        assign_user_to_page(page_b, self.user_normal, can_view=True,
                            can_change=True)
        cached_permissions = get_permission_cache(self.user_normal, "change_page")
        self.assertIsNone(cached_permissions)

        live_permissions = get_change_id_list(self.user_normal, Site.objects.get_current())
        cached_permissions_permissions = get_permission_cache(self.user_normal,
                                                              "change_page")
        self.assertEqual(live_permissions, [page_b.id])
        self.assertEqual(cached_permissions_permissions, live_permissions)

        self.home_page.save()
        cached_permissions = get_permission_cache(self.user_normal, "change_page")
        self.assertIsNone(cached_permissions)