Check backward compatibility with tox
This commit is contained in:
@ -34,8 +34,8 @@ matrix:
|
||||
env: TOXENV=py36-django22-wagtail26
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django22-wagtail26-geoip2
|
||||
- python: 3.6
|
||||
env: TOXENV=py36-django111-wagtail22
|
||||
# - python: 3.6
|
||||
# env: TOXENV=py36-django111-wagtail22
|
||||
|
||||
install:
|
||||
- pip install tox codecov
|
||||
|
2
setup.py
2
setup.py
@ -16,7 +16,7 @@ tests_require = [
|
||||
'flake8',
|
||||
'freezegun==0.3.8',
|
||||
'pytest-cov==2.5.1',
|
||||
'pytest-django==3.1.2',
|
||||
'pytest-django==4.1.0',
|
||||
'pytest-pythonpath==0.7.2',
|
||||
'pytest-sugar==0.9.1',
|
||||
'pytest==6.1.2',
|
||||
|
@ -10,7 +10,7 @@ from wagtail_personalisation.models import PersonalisablePageMetadata
|
||||
try:
|
||||
from wagtail.core.models import Locale
|
||||
|
||||
class LocaleFactory(factory.django.DjangoModelFactory):
|
||||
class LocaleFactory(factory.DjangoModelFactory):
|
||||
language_code = "en"
|
||||
|
||||
class Meta:
|
||||
|
@ -28,14 +28,14 @@ def site():
|
||||
return site
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.fixture(autouse=True)
|
||||
def segmented_page(site):
|
||||
page = ContentPageFactory(parent=site.root_page, slug='personalised')
|
||||
segment = SegmentFactory()
|
||||
return page.personalisation_metadata.copy_for_segment(segment)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture(autouse=True)
|
||||
def rf():
|
||||
"""RequestFactory instance"""
|
||||
return RequestFactory()
|
||||
@ -51,6 +51,6 @@ class RequestFactory(BaseRequestFactory):
|
||||
return request
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.fixture(autouse=True)
|
||||
def user(django_user_model):
|
||||
return django_user_model.objects.create(username='user')
|
||||
|
@ -1,4 +1,5 @@
|
||||
import os
|
||||
from importlib.util import find_spec
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
@ -58,10 +59,14 @@ MIDDLEWARE = (
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
|
||||
'wagtail.contrib.legacy.sitemiddleware.SiteMiddleware',
|
||||
)
|
||||
|
||||
if find_spec('wagtail.contrib.legacy'):
|
||||
MIDDLEWARE += ('wagtail.contrib.legacy.sitemiddleware.SiteMiddleware',)
|
||||
else:
|
||||
MIDDLEWARE += ('wagtail.core.middleware.SiteMiddleware', )
|
||||
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'wagtail_personalisation',
|
||||
|
||||
|
@ -31,11 +31,6 @@ def test_metadata_page_has_variants(segmented_page):
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_content_page_model():
|
||||
try:
|
||||
from tests.factories.page import LocaleFactory
|
||||
LocaleFactory()
|
||||
except ImportError:
|
||||
pass
|
||||
page = ContentPageFactory()
|
||||
qs = models.ContentPage.objects.all()
|
||||
assert page in qs
|
||||
@ -81,5 +76,8 @@ def test_sitemap_generation_for_variants_is_disabled(segmented_page):
|
||||
@pytest.mark.django_db
|
||||
def test_segment_edit_view(site, client, django_user_model):
|
||||
test_segment = SegmentFactory()
|
||||
new_panel = test_segment.panels[1].children[0].bind_to(model=Segment)
|
||||
try:
|
||||
new_panel = test_segment.panels[1].children[0].bind_to(model=Segment)
|
||||
except AttributeError:
|
||||
new_panel = test_segment.panels[1].children[0].bind_to_model(Segment)
|
||||
assert new_panel.related.name == "wagtail_personalisation_timerules"
|
||||
|
@ -18,8 +18,6 @@ except ImportError:
|
||||
|
||||
@pytest.fixture
|
||||
def rootpage():
|
||||
if locale_factory:
|
||||
LocaleFactory()
|
||||
return ContentPageFactory(parent=None, path='/', depth=0, title='root')
|
||||
|
||||
|
||||
@ -81,8 +79,6 @@ def test_exclude_variants_with_pages_querysets():
|
||||
'''
|
||||
Test that excludes variant works for querysets
|
||||
'''
|
||||
if locale_factory:
|
||||
LocaleFactory()
|
||||
for i in range(5):
|
||||
page = ContentPageFactory(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i))
|
||||
page.save()
|
||||
@ -98,8 +94,6 @@ def test_exclude_variants_with_pages_querysets_not_canonical():
|
||||
Test that excludes variant works for querysets with
|
||||
personalisation_metadata canonical False
|
||||
'''
|
||||
if locale_factory:
|
||||
LocaleFactory()
|
||||
for i in range(5):
|
||||
page = ContentPageFactory(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i))
|
||||
page.save()
|
||||
@ -120,8 +114,6 @@ def test_exclude_variants_with_pages_querysets_meta_none():
|
||||
'''
|
||||
Test that excludes variant works for querysets with meta as none
|
||||
'''
|
||||
if locale_factory:
|
||||
LocaleFactory()
|
||||
for i in range(5):
|
||||
page = ContentPageFactory(path="/" + str(i), depth=0, url_path="/", title="Hoi " + str(i))
|
||||
page.save()
|
||||
|
@ -106,5 +106,5 @@ def test_segment_delete_view_raises_permission_denied(rf, segmented_page, user):
|
||||
)
|
||||
view.request = request
|
||||
message = 'User have no permission to delete variant page objects.'
|
||||
with pytest.raises(PermissionDenied, message=message):
|
||||
with pytest.raises(PermissionDenied):
|
||||
view.delete_instance()
|
||||
|
Reference in New Issue
Block a user