def test_recover_with_apphook(self):
        """
        Test that you can recover a page
        """
        from cms.utils.helpers import make_revision_with_plugins
        from cms.utils.reversion_hacks import create_revision, revision_manager

        self.assertEqual(Page.objects.count(), 2)

        with self.login_user_context(self.user):

            page_data = self.get_new_page_data_dbfields()
            page_data['apphook'] = 'SampleApp'
            page_data['apphook_namespace'] = 'SampleApp'

            with create_revision():
                # Need to create page manually to add apphooks
                page = create_page(**page_data)

                # Assert page has apphooks
                self.assertEqual(page.application_urls, 'SampleApp')
                self.assertEqual(page.application_namespace, 'SampleApp')

                # Create revision
                make_revision_with_plugins(page, user=None, message="Initial version")

            page_pk = page.pk

            # Delete the page through the admin
            data = {'post': 'yes'}
            response = self.client.post(URL_CMS_PAGE_DELETE % page.pk, data)
            self.assertRedirects(response, URL_CMS_PAGE)

            # Assert page was truly deleted
            self.assertEqual(Page.objects.filter(pk=page_pk).count(), 0)

            versions_qs = revision_manager.get_deleted(Page).order_by("-pk")
            version = versions_qs[0]

            recover_url = URL_CMS_PAGE + version.pk % "recover/%s/"

            # Recover deleted page
            page_form_data = self.get_pagedata_from_dbfields(page_data)
            self.client.post(recover_url, page_form_data)

            # Verify page was recovered correctly
            self.assertEqual(Page.objects.filter(pk=page_pk).count(), 1)

            # Get recovered page
            page = Page.objects.get(pk=page_pk)

            # Verify apphook and apphook namespace are set on page.
            self.assertEqual(page.application_urls, 'SampleApp')
            self.assertEqual(page.application_namespace, 'SampleApp')
dataset/ETHPy150Open divio/django-cms/cms/tests/test_reversion_tests.py/ReversionTestCase.test_recover_with_apphook/swapped operands of `%`