def test_unindex_wagtail_page_signal(self):
     page = self.page
     index_wagtail_page(page)
     page.delete()
     # Assert that previously created search document was deleted
     self.assertEqual(
         SearchDocument.objects.filter(
             key=KEY_FORMAT.format(page.pk)).count(), 0)
    def test_index_wagtail_page(self):
        page = self.page
        index_wagtail_page(page)

        # Assert that a search document was created
        self.assertEqual(
            SearchDocument.objects.filter(
                key=KEY_FORMAT.format(page.pk)).count(), 1)
    def test_non_routable_wagtail_page(self):
        # Wagtail can only route a page if it starts with the same
        # path as Site.root_page.url, which in the case of this test
        # is '/', so the non-routable URL should not start with '/'.
        page = HomePageFactory.build(path='non_root_route')
        index_wagtail_page(page)

        # Document should not be created nor errors raised
        self.assertEqual(
            SearchDocument.objects.filter(
                key=KEY_FORMAT.format(page.pk)).count(), 0)
    def test_indexed_page_should_have_correct_content(self):
        blog_index = BlogIndexPageFactory(
            parent=self.page,
            title="News",
            body=[('rich_text', RichText('hello world'))],
        )
        index_wagtail_page(blog_index)

        self.assertEqual(
            SearchDocument.objects.filter(search_vector='hello').count(), 1)

        self.assertEqual(
            SearchDocument.objects.get(
                key=KEY_FORMAT.format(blog_index.pk)).search_content,
            blog_index.get_search_content().as_string(),
        )
Ejemplo n.º 5
0
def index_wagtail_page_(sender, instance, **kwargs):
    return index_wagtail_page(instance)