8

Make changes backwards compatible

This commit is contained in:
Marcel Hekking
2020-11-25 12:08:42 +01:00
parent d074ef85b9
commit ffd839159b
6 changed files with 47 additions and 17 deletions

View File

@@ -2,15 +2,24 @@ import pytest
from django.test import override_settings
from wagtail.core.models import Page as WagtailPage
from tests.factories.page import (
ContentPageFactory, LocaleFactory, PersonalisablePageMetadataFactory)
from tests.factories.page import (ContentPageFactory, PersonalisablePageMetadataFactory)
from wagtail_personalisation.utils import (
can_delete_pages, exclude_variants, get_client_ip, impersonate_other_page)
locale_factory = False
try:
from tests.factories.page import LocaleFactory
locale_factory = True
except ImportError:
pass
@pytest.fixture
def rootpage():
LocaleFactory()
if locale_factory:
LocaleFactory()
return ContentPageFactory(parent=None, path='/', depth=0, title='root')
@@ -72,7 +81,8 @@ def test_exclude_variants_with_pages_querysets():
'''
Test that excludes variant works for querysets
'''
LocaleFactory()
if locale_factory:
LocaleFactory()
for i in range(5):
page = ContentPageFactory(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i))
page.save()
@@ -88,7 +98,8 @@ def test_exclude_variants_with_pages_querysets_not_canonical():
Test that excludes variant works for querysets with
personalisation_metadata canonical False
'''
LocaleFactory()
if locale_factory:
LocaleFactory()
for i in range(5):
page = ContentPageFactory(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i))
page.save()
@@ -109,7 +120,8 @@ def test_exclude_variants_with_pages_querysets_meta_none():
'''
Test that excludes variant works for querysets with meta as none
'''
LocaleFactory()
if locale_factory:
LocaleFactory()
for i in range(5):
page = ContentPageFactory(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i))
page.save()