7

Compare commits

...

19 Commits

Author SHA1 Message Date
686f180081 Bump version: 0.14.0 → 0.15.0 2021-07-09 11:00:14 +02:00
9b1dbe35cb fix(tox): use correct format command for current package 2021-06-28 12:15:24 +02:00
7e0594e341 fix(tox): add new tox setup for github actions 2021-06-28 12:13:55 +02:00
0c19456053 Merge pull request #212 from marcelhekking/make_compatible_with_latest_wagtail_version
Make compatible with latest wagtail version
2021-06-28 12:10:31 +02:00
18140f76ab chore(ci): trigger github actions on pr 2021-06-28 12:08:58 +02:00
88b17ceeb8 chore(ci): add github actions python test step 2021-06-28 12:06:43 +02:00
570de7d128 Flake-import failed 2021-06-24 08:38:06 +02:00
b82d5165c3 Take up wagtail 2.11 in Travis test matrix and tox settings 2021-06-24 08:16:29 +02:00
8d802dbbf4 Restore original travis settings 2021-06-24 07:58:11 +02:00
9274073c68 Fix test errors 2021-06-24 07:57:31 +02:00
1f1264cf95 Fix typo 2020-11-25 16:40:15 +01:00
3f16ad686e Remove obsolete line 2020-11-25 15:54:32 +01:00
7101b63122 Check backward compatibility with tox 2020-11-25 15:50:52 +01:00
ffd839159b Make changes backwards compatible 2020-11-25 12:08:42 +01:00
d074ef85b9 No need for these settings 2020-11-24 09:10:14 +01:00
f3e403bec6 Make compatible with latest Wagtail version (2.11.2) 2020-11-24 09:05:20 +01:00
137b5b411c Merge pull request #203 from davisnando/master
Fix is_authenticated 'bool' object is not callable error
2020-01-24 08:22:06 +01:00
39f3500813 Bump version: 0.13.0 → 0.14.0 2019-09-27 09:16:15 +02:00
06569a3cc1 Fix 'bool' object is not callable error 2019-08-27 11:43:39 +02:00
16 changed files with 259 additions and 35 deletions

161
.github/workflows/python-test.yml vendored Normal file
View File

@ -0,0 +1,161 @@
---
name: Python Tests
on: [push, pull_request]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: pip install tox
- name: Validate formatting
run: tox -e format
test:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
tox_env:
- py36-dj22-wt25
- py36-dj22-wt26
- py36-dj22-wt27
- py36-dj22-wt28
- py36-dj22-wt29
- py36-dj22-wt210
- py36-dj22-wt211
- py36-dj22-wt212
- py36-dj22-wt213
- py37-dj22-wt25
- py37-dj22-wt26
- py37-dj22-wt27
- py37-dj22-wt28
- py37-dj22-wt29
- py37-dj22-wt210
- py37-dj22-wt211
- py37-dj22-wt212
- py37-dj22-wt213
- py38-dj22-wt25
- py38-dj22-wt26
- py38-dj22-wt27
- py38-dj22-wt28
- py38-dj22-wt29
- py38-dj22-wt210
- py38-dj22-wt211
- py38-dj22-wt212
- py38-dj22-wt213
- py37-dj30-wt28
- py37-dj30-wt29
- py37-dj30-wt210
- py37-dj30-wt211
- py37-dj30-wt212
- py37-dj30-wt213
- py38-dj30-wt28
- py38-dj30-wt29
- py38-dj30-wt210
- py38-dj30-wt211
- py38-dj30-wt212
- py38-dj30-wt213
include:
- python-version: 3.6
tox_env: py36-dj22-wt25
- python-version: 3.6
tox_env: py36-dj22-wt26
- python-version: 3.6
tox_env: py36-dj22-wt27
- python-version: 3.6
tox_env: py36-dj22-wt28
- python-version: 3.6
tox_env: py36-dj22-wt29
- python-version: 3.6
tox_env: py36-dj22-wt210
- python-version: 3.6
tox_env: py36-dj22-wt211
- python-version: 3.6
tox_env: py36-dj22-wt212
- python-version: 3.6
tox_env: py36-dj22-wt213
- python-version: 3.7
tox_env: py37-dj22-wt25
- python-version: 3.7
tox_env: py37-dj22-wt26
- python-version: 3.7
tox_env: py37-dj22-wt27
- python-version: 3.7
tox_env: py37-dj22-wt28
- python-version: 3.7
tox_env: py37-dj22-wt29
- python-version: 3.7
tox_env: py37-dj22-wt210
- python-version: 3.7
tox_env: py37-dj22-wt211
- python-version: 3.7
tox_env: py37-dj22-wt212
- python-version: 3.7
tox_env: py37-dj22-wt213
- python-version: 3.8
tox_env: py38-dj22-wt25
- python-version: 3.8
tox_env: py38-dj22-wt26
- python-version: 3.8
tox_env: py38-dj22-wt27
- python-version: 3.8
tox_env: py38-dj22-wt28
- python-version: 3.8
tox_env: py38-dj22-wt29
- python-version: 3.8
tox_env: py38-dj22-wt210
- python-version: 3.8
tox_env: py38-dj22-wt211
- python-version: 3.8
tox_env: py38-dj22-wt212
- python-version: 3.8
tox_env: py38-dj22-wt213
- python-version: 3.7
tox_env: py37-dj30-wt28
- python-version: 3.7
tox_env: py37-dj30-wt29
- python-version: 3.7
tox_env: py37-dj30-wt210
- python-version: 3.7
tox_env: py37-dj30-wt211
- python-version: 3.7
tox_env: py37-dj30-wt212
- python-version: 3.7
tox_env: py37-dj30-wt213
- python-version: 3.8
tox_env: py38-dj30-wt28
- python-version: 3.8
tox_env: py38-dj30-wt29
- python-version: 3.8
tox_env: py38-dj30-wt210
- python-version: 3.8
tox_env: py38-dj30-wt211
- python-version: 3.8
tox_env: py38-dj30-wt212
- python-version: 3.8
tox_env: py38-dj30-wt213
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
run: tox -e ${{ matrix.tox_env }} --index-url=https://pypi.python.org/simple/
- name: Prepare artifacts
run: mkdir -p .coverage-data && mv .coverage.* .coverage-data/
- uses: actions/upload-artifact@master
with:
name: coverage-data
path: .coverage-data/

View File

@ -36,6 +36,8 @@ matrix:
env: TOXENV=py36-django22-wagtail26-geoip2
- python: 3.6
env: TOXENV=py36-django111-wagtail22
- python: 3.6
env: TOXENV=py36-django22-wagtail211-geoip2
install:
- pip install tox codecov

View File

@ -62,10 +62,10 @@ author = 'Lab Digital BV'
# built documents.
#
# The short X.Y version.
version = '0.13.0'
version = '0.15.0'
# The full version, including alpha/beta/rc tags.
release = '0.13.0'
release = '0.15.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@ -14,6 +14,7 @@ from __future__ import absolute_import, unicode_literals
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
from importlib.util import find_spec
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
BASE_DIR = os.path.dirname(PROJECT_DIR)
@ -78,11 +79,14 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'wagtail.core.middleware.SiteMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
]
if find_spec('wagtail.contrib.legacy'):
MIDDLEWARE += ('wagtail.contrib.legacy.sitemiddleware.SiteMiddleware',)
else:
MIDDLEWARE += ('wagtail.core.middleware.SiteMiddleware', )
ROOT_URLCONF = 'sandbox.urls'
TEMPLATES = [

View File

@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.13.0
current_version = 0.15.0
commit = true
tag = true
tag_name = {new_version}
@ -28,4 +28,3 @@ omit = src/**/migrations/*.py
[bumpversion:file:setup.py]
[bumpversion:file:docs/conf.py]

View File

@ -12,14 +12,14 @@ tests_require = [
'factory_boy==2.8.1',
'flake8-blind-except',
'flake8-debugger',
'flake8-imports',
'flake8-isort',
'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==3.4.2',
'pytest==6.1.2',
'wagtail_factories==1.1.0',
'pytest-mock==1.6.3',
]
@ -35,7 +35,7 @@ with open('README.rst') as fh:
setup(
name='wagtail-personalisation',
version='0.13.0',
version='0.15.0',
description='A Wagtail add-on for showing personalized content',
author='Lab Digital BV and others',
author_email='opensource@labdigital.nl',

View File

@ -1,19 +1,19 @@
from datetime import datetime
import functools
from importlib import import_module
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import AnonymousUser
from django.contrib.staticfiles.templatetags.staticfiles import static
from django.templatetags.static import static
from django.test.client import RequestFactory
from django.utils.lru_cache import lru_cache
from django.utils.translation import ugettext_lazy as _
from wagtail.admin.forms import WagtailAdminModelForm
SessionStore = import_module(settings.SESSION_ENGINE).SessionStore
@lru_cache(maxsize=1000)
@functools.lru_cache(maxsize=1000)
def user_from_data(user_id):
User = get_user_model()
try:

View File

@ -419,7 +419,7 @@ class UserIsLoggedInRule(AbstractBaseRule):
verbose_name = _('Logged in Rule')
def test_user(self, request=None):
return request.user.is_authenticated() == self.is_logged_in
return request.user.is_authenticated == self.is_logged_in
def description(self):
return {

View File

@ -11,7 +11,12 @@ from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from wagtail.admin import messages
from wagtail.admin.site_summary import PagesSummaryItem, SummaryItem
from wagtail.admin.views.pages import get_valid_next_url_from_request
try:
from wagtail.admin.views.pages.utils import get_valid_next_url_from_request
except ModuleNotFoundError:
from wagtail.admin.views.pages import get_valid_next_url_from_request # noqa
from wagtail.admin.widgets import Button, ButtonWithDropdownFromHook
from wagtail.core import hooks
from wagtail.core.models import Page
@ -23,6 +28,8 @@ from wagtail_personalisation.models import PersonalisablePageMetadata
logger = logging.getLogger(__name__)
@hooks.register('register_admin_urls')
def register_admin_urls():
"""Adds the administration urls for the personalisation apps."""

View File

@ -7,6 +7,16 @@ from wagtail_factories.factories import PageFactory
from tests.site.pages import models
from wagtail_personalisation.models import PersonalisablePageMetadata
try:
from wagtail.core.models import Locale
class LocaleFactory(factory.DjangoModelFactory):
language_code = "en"
class Meta:
model = Locale
except ImportError:
pass
class ContentPageFactory(PageFactory):
parent = None

View File

@ -23,7 +23,7 @@ def site():
return site
@pytest.fixture
@pytest.fixture()
def segmented_page(site):
page = ContentPageFactory(parent=site.root_page, slug='personalised')
segment = SegmentFactory()
@ -46,6 +46,6 @@ class RequestFactory(BaseRequestFactory):
return request
@pytest.fixture
@pytest.fixture()
def user(django_user_model):
return django_user_model.objects.create(username='user')

View File

@ -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.core.middleware.SiteMiddleware',
)
if find_spec('wagtail.contrib.legacy'):
MIDDLEWARE += ('wagtail.contrib.legacy.sitemiddleware.SiteMiddleware',)
else:
MIDDLEWARE += ('wagtail.core.middleware.SiteMiddleware', )
INSTALLED_APPS = (
'wagtail_personalisation',

View File

@ -76,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"

View File

@ -2,12 +2,20 @@ import pytest
from django.test import override_settings
from wagtail.core.models import Page as WagtailPage
from tests.factories.page import (
ContentPageFactory, 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():
return ContentPageFactory(parent=None, path='/', depth=0, title='root')

View File

@ -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()

49
tox.ini
View File

@ -1,21 +1,37 @@
[tox]
envlist = py{36}-django{111,20,21,22}-wagtail{20,21,22,23,24,25,26}{,-geoip2},lint
envlist =
flake8
py{36,37,38}-dj{22}-wt{25,26,27,28,29,210,211,212,213}
py{37,38}-dj{30,31}-wt{28,29,210,211,212,213}
[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38
[testenv]
basepython = python3.6
basepython =
py36: python3.6
py37: python3.7
py38: python3.8
commands = coverage run --parallel -m pytest -rs {posargs}
extras = test
deps =
django20: django>=2.0,<2.1
django21: django>=2.1,<2.2
django22: django>=2.2,<2.3
wagtail20: wagtail>=2.0,<2.1
wagtail21: wagtail>=2.1,<2.2
wagtail22: wagtail>=2.2,<2.3
wagtail23: wagtail>=2.3,<2.4
wagtail24: wagtail>=2.4,<2.5
wagtail25: wagtail>=2.5,<2.6
wagtail26: wagtail>=2.6,<2.7
dj22: Django>=2.2.8,<2.3
dj30: Django>=3.0,<3.1
dj31: Django>=3.1,<3.2
wt23: wagtail>=2.3,<2.4
wt24: wagtail>=2.4,<2.5
wt25: wagtail>=2.5,<2.6
wt26: wagtail>=2.6,<2.7
wt27: wagtail>=2.7,<2.8
wt28: wagtail>=2.8,<2.9
wt29: wagtail>=2.9,<2.10
wt210: wagtail>=2.10,<2.11
wt211: wagtail>=2.11,<2.12
wt212: wagtail>=2.12,<2.13
wt213: wagtail>=2.13,<2.14
geoip2: geoip2
django111: django>=1.11,<1.12
@ -33,3 +49,12 @@ deps = flake8==3.5.0
commands =
flake8 src tests setup.py
isort -q --recursive --diff src/ tests/
[testenv:format]
basepython = python3.8
deps =
isort
black
skip_install = true
commands =
black --check setup.py src/wagtail_personalisation/ tests/