def site():
    root_page = ContentPageFactory(parent=None, slug="")
    site = SiteFactory(is_default_site=True, root_page=root_page)

    page1 = ContentPageFactory(parent=root_page, slug="content-page")
    page2 = TaggableContentPageFactory(parent=root_page, slug="taggable-content-page")
    ContentPageFactory(parent=page1, slug="content-page-child")
    TaggableContentPageFactory(parent=page2, slug="taggable-content-page-child")

    return site
Beispiel #2
0
def site():
    root_page = ContentPageFactory(parent=None, slug="")
    site = SiteFactory(is_default_site=True, root_page=root_page)

    page1 = ContentPageFactory(parent=root_page, slug="page-1")
    page2 = ContentPageFactory(parent=root_page, slug="page-2")
    ContentPageFactory(parent=page1, slug="page-1-1")
    ContentPageFactory(parent=page2, slug="page-2-1")

    return site
def site():
    root_page = ContentPageFactory(parent=None, slug='')
    site = SiteFactory(is_default_site=True, root_page=root_page)

    page1 = ContentPageFactory(parent=root_page, slug='page-1')
    page2 = ContentPageFactory(parent=root_page, slug='page-2')
    ContentPageFactory(parent=page1, slug='page-1-1')
    ContentPageFactory(parent=page2, slug='page-2-1')

    RegularPageFactory(parent=root_page, slug='regular')
    return site
Beispiel #4
0
def test_exclude_variants_with_pages_querysets():
    '''
    Test that excludes variant works for querysets
    '''
    for i in range(5):
        page = ContentPageFactory(path="/" + str(i),
                                  depth=0,
                                  url_path="/",
                                  title="Hoi " + str(i))
        page.save()
    pages = WagtailPage.objects.all().specific().order_by('id')

    result = exclude_variants(pages)
    assert type(result) == type(pages)
    assert set(result.values_list('pk', flat=True)) == set(
        pages.values_list('pk', flat=True))
Beispiel #5
0
def site():
    try:
        from wagtail.core.models import Locale  # noqa
        from tests.factories.locale import LocaleFactory

        LocaleFactory()
    except:  # noqa: E722
        pass

    root_page = ContentPageFactory(parent=None, slug="")
    site = SiteFactory(is_default_site=True, root_page=root_page)

    page1 = ContentPageFactory(parent=root_page, slug="content-page")
    page2 = TaggableContentPageFactory(parent=root_page,
                                       slug="taggable-content-page")
    ContentPageFactory(parent=page1, slug="content-page-child")
    TaggableContentPageFactory(parent=page2,
                               slug="taggable-content-page-child")

    return site
def test_custom_delete_page_view_deletes_variants_of_child_pages(rf, segmented_page, user):
    """
    Regression test for deleting pages that have children with variants
    """
    post_request = rf.post('/')
    user.is_superuser = True
    rf.user = user
    canonical_page = segmented_page.personalisation_metadata.canonical_page
    # Create a child with a variant
    child_page = ContentPageFactory(parent=canonical_page, slug='personalised-child')
    child_page.personalisation_metadata.copy_for_segment(segmented_page.personalisation_metadata.segment)
    # A ProtectedError would be raised if the bug persists
    wagtail_hooks.delete_related_variants(
        post_request, canonical_page
    )
Beispiel #7
0
def test_exclude_variants_with_pages_querysets_not_canonical():
    '''
    Test that excludes variant works for querysets with
    personalisation_metadata canonical False
    '''
    for i in range(5):
        page = ContentPageFactory(path="/" + str(i),
                                  depth=0,
                                  url_path="/",
                                  title="Hoi " + str(i))
        page.save()
    pages = WagtailPage.objects.all().specific().order_by('id')
    # add variants
    for page in pages:
        variant = ContentPageFactory(title='variant %d' % page.pk)
        page.personalisation_metadata = PersonalisablePageMetadataFactory(
            canonical_page=page, variant=variant)
        page.save()

    pages = WagtailPage.objects.all().specific()
    result = exclude_variants(pages)
    assert type(result) == type(pages)
    assert result.count() < pages.count()
Beispiel #8
0
def test_exclude_variants_with_pages_querysets_meta_none():
    '''
    Test that excludes variant works for querysets with meta as none
    '''
    for i in range(5):
        page = ContentPageFactory(path="/" + str(i),
                                  depth=0,
                                  url_path="/",
                                  title="Hoi " + str(i))
        page.save()
    pages = WagtailPage.objects.all().specific().order_by('id')
    # add variants
    for page in pages:
        page.personalisation_metadata = PersonalisablePageMetadataFactory(
            canonical_page=page, variant=page)
        page.save()

    pages = WagtailPage.objects.all().specific()
    result = exclude_variants(pages)
    assert type(result) == type(pages)
    assert set(result.values_list('pk', flat=True)) == set(
        pages.values_list('pk', flat=True))
Beispiel #9
0
def test_content_page_model():
    page = ContentPageFactory()
    qs = models.ContentPage.objects.all()
    assert page in qs
def segmented_page(site):
    page = ContentPageFactory(parent=site.root_page, slug='personalised')
    segment = SegmentFactory()
    return page.personalisation_metadata.copy_for_segment(segment)
def otherpage(rootpage):
    return ContentPageFactory(parent=rootpage, path='/bye', title='Bye')
def page(rootpage):
    return ContentPageFactory(parent=rootpage, path='/hi', title='Hi')
def rootpage():
    return ContentPageFactory(parent=None, path='/', depth=0, title='root')