@override_settings(ROOT_URLCONF='cms.test_utils.project.urls_3')
    def test_get_page_for_apphook_on_preview_or_edit(self):
        if get_user_model().USERNAME_FIELD == 'email':
            superuser = get_user_model().objects.create_superuser('admin', 'admin@admin.com', 'admin@admin.com')
        else:
            superuser = get_user_model().objects.create_superuser('admin', 'admin@admin.com', 'admin')

        page = create_page("home", "nav_playground.html", "en",
                           created_by=superuser, published=True, apphook=APP_NAME)
        create_title('de', page.get_title(), page)
        page.publish('en')
        page.publish('de')
        page.save()
        public_page = page.get_public_object()

        with self.login_user_context(superuser):
            with force_language("en"):
                path = reverse('sample-settings')
                request = self.get_request(path + '?%s' % get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON'))
                request.LANGUAGE_CODE = 'en'
                attached_to_page = applications_page_check(request, path=path[1:])  # strip leading slash
                response = self.client.get(path+"?edit")
                self.assertContains(response, '?redirect=')
            with force_language("de"):
                path = reverse('sample-settings')
                request = self.get_request(path + '?%s' % get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON'))
                request.LANGUAGE_CODE = 'de'
                attached_to_page = applications_page_check(request, path=path[1:])  # strip leading slash
                self.assertEqual(attached_to_page.pk, public_page.pk)
dataset/ETHPy150Open divio/django-cms/cms/tests/test_apphooks.py/ApphooksTestCase.test_get_page_for_apphook_on_preview_or_edit/original