def test_copy_language_backend(self):
        """
        Testing how the copy button works.
        It calls the ``get_placeholder_data_view`` function.
        """
        self.admin_site.register(PlaceholderFieldTestPage,
                                 PlaceholderFieldTestPageAdmin)
        modeladmin = self.admin_site._registry[PlaceholderFieldTestPage]

        page = factories.create_page()
        placeholder = factories.create_placeholder(page=page)
        item1 = factories.create_content_item(RawHtmlTestItem,
                                              placeholder=placeholder,
                                              html="AA")
        item2 = factories.create_content_item(RawHtmlTestItem,
                                              placeholder=placeholder,
                                              html="BB")

        request = self._get_request(
            admin_urlname(page._meta, "get_placeholder_data"))
        data = modeladmin.get_placeholder_data_view(request, page.pk).jsondata
        self.assertEqual(len(data["formset_forms"]), 2)
        self.assertEqual(data["formset_forms"][0]["model"], "RawHtmlTestItem")
        self.assertEqual(data["formset_forms"][0]["contentitem_id"], item1.pk)
        self.assertEqual(data["formset_forms"][1]["contentitem_id"], item2.pk)
        self.assertTrue("AA" in data["formset_forms"][0]["html"])
示例#2
0
    def test_copy_language_backend(self):
        """
        Testing how the copy button works.
        It calls the ``get_placeholder_data_view`` function.
        """
        self.admin_site.register(PlaceholderFieldTestPage,
                                 PlaceholderFieldTestPageAdmin)
        modeladmin = self.admin_site._registry[PlaceholderFieldTestPage]

        page = factories.create_page()
        placeholder = factories.create_placeholder(page=page)
        item1 = factories.create_content_item(RawHtmlTestItem,
                                              placeholder=placeholder,
                                              html='AA')
        item2 = factories.create_content_item(RawHtmlTestItem,
                                              placeholder=placeholder,
                                              html='BB')

        request = self._get_request(
            admin_urlname(page._meta, 'get_placeholder_data'))
        data = modeladmin.get_placeholder_data_view(request, page.pk).jsondata
        self.assertEqual(len(data['formset_forms']), 2)
        self.assertEqual(data['formset_forms'][0]['model'], 'RawHtmlTestItem')
        self.assertEqual(data['formset_forms'][0]['contentitem_id'], item1.pk)
        self.assertEqual(data['formset_forms'][1]['contentitem_id'], item2.pk)
        self.assertTrue('AA' in data['formset_forms'][0]['html'])
示例#3
0
    def test_render_redirect(self):
        cache.clear()
        page = factories.create_page()
        placeholder = factories.create_placeholder(page=page)
        factories.create_content_item(RedirectTestItem, placeholder=placeholder, html='MEDIA_TEST')

        response = self.client.get(reverse('testpage', args=(page.pk,)))
        self.assertTrue(response.status_code, 301)
        self.assertIsInstance(response, HttpResponseRedirect)
        self.assertTrue(response['Location'].endswith('/contact/success/'))
    def test_render_redirect(self):
        cache.clear()
        page = factories.create_page()
        placeholder = factories.create_placeholder(page=page)
        factories.create_content_item(RedirectTestItem, placeholder=placeholder, html="MEDIA_TEST")

        response = self.client.get(reverse("testpage", args=(page.pk,)))
        self.assertTrue(response.status_code, 301)
        self.assertIsInstance(response, HttpResponseRedirect)
        self.assertTrue(response["Location"].endswith("/contact/success/"))
    def test_copy_language_backend(self):
        """
        Testing how the copy button works.
        It calls the ``get_placeholder_data_view`` function.
        """
        self.admin_site.register(PlaceholderFieldTestPage, PlaceholderFieldTestPageAdmin)
        modeladmin = self.admin_site._registry[PlaceholderFieldTestPage]

        page = factories.create_page()
        placeholder = factories.create_placeholder(page=page)
        item1 = factories.create_content_item(RawHtmlTestItem, placeholder=placeholder, html='AA')
        item2 = factories.create_content_item(RawHtmlTestItem, placeholder=placeholder, html='BB')

        request = self._get_request(admin_urlname(page._meta, 'get_placeholder_data'))
        data = modeladmin.get_placeholder_data_view(request, page.pk).jsondata
        self.assertEqual(len(data['formset_forms']), 2)
        self.assertEqual(data['formset_forms'][0]['model'], 'RawHtmlTestItem')
        self.assertEqual(data['formset_forms'][0]['contentitem_id'], item1.pk)
        self.assertEqual(data['formset_forms'][1]['contentitem_id'], item2.pk)
        self.assertTrue('AA' in data['formset_forms'][0]['html'])