Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
7ced6db126 | |||
c6ce67c9c9 | |||
3df3fc0b16 | |||
a00929846e | |||
49fba11049 | |||
e3488e87ad | |||
808aa6d202 | |||
efb060cc6e | |||
414afa5269 | |||
b3f0ac2d58 | |||
4f9c18d2cf | |||
a4a283e4f3 | |||
30318549e2 | |||
f19de241b0 | |||
95ecd8d200 | |||
6436b85b1d | |||
06471248d3 | |||
e3df03f559 | |||
0a42ce3eeb | |||
e5068894c3 |
@ -4,9 +4,11 @@ language: python
|
|||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
# Django 1.9, Wagtail 1.9
|
|
||||||
- python: 2.7
|
- python: 2.7
|
||||||
env: TOXENV=py27-django19-wagtail19
|
env: lint
|
||||||
|
|
||||||
|
- python: 2.7
|
||||||
|
env: TOXENV=py27-django111-wagtail113
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- pip install tox codecov
|
- pip install tox codecov
|
||||||
|
@ -55,10 +55,10 @@ author = 'Lab Digital BV'
|
|||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '0.10.1'
|
version = '0.10.4'
|
||||||
|
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '0.10.1'
|
release = '0.10.4'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.10.1
|
current_version = 0.10.4
|
||||||
commit = true
|
commit = true
|
||||||
tag = true
|
tag = true
|
||||||
tag_name = {new_version}
|
tag_name = {new_version}
|
||||||
|
4
setup.py
4
setup.py
@ -2,7 +2,7 @@ import re
|
|||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
install_requires = [
|
install_requires = [
|
||||||
'wagtail>=1.9,<1.11',
|
'wagtail>=1.10,<1.14',
|
||||||
'user-agents>=1.0.1',
|
'user-agents>=1.0.1',
|
||||||
'wagtailfontawesome>=1.0.6',
|
'wagtailfontawesome>=1.0.6',
|
||||||
]
|
]
|
||||||
@ -32,7 +32,7 @@ with open('README.rst') as fh:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='wagtail-personalisation-molo',
|
name='wagtail-personalisation-molo',
|
||||||
version='0.10.1',
|
version='0.10.4',
|
||||||
description='A forked version of Wagtail add-on for showing personalized content',
|
description='A forked version of Wagtail add-on for showing personalized content',
|
||||||
author='Praekelt.org',
|
author='Praekelt.org',
|
||||||
author_email='dev@praekeltfoundation.org',
|
author_email='dev@praekeltfoundation.org',
|
||||||
|
@ -3,7 +3,6 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.models import F
|
from django.db.models import F
|
||||||
from django.utils.module_loading import import_string
|
from django.utils.module_loading import import_string
|
||||||
from django.utils import timezone
|
|
||||||
|
|
||||||
from wagtail_personalisation.models import Segment
|
from wagtail_personalisation.models import Segment
|
||||||
from wagtail_personalisation.rules import AbstractBaseRule
|
from wagtail_personalisation.rules import AbstractBaseRule
|
||||||
@ -133,12 +132,13 @@ class SessionSegmentsAdapter(BaseSegmentsAdapter):
|
|||||||
if page_visits:
|
if page_visits:
|
||||||
for page_visit in page_visits:
|
for page_visit in page_visits:
|
||||||
page_visit['count'] += 1
|
page_visit['count'] += 1
|
||||||
|
page_visit['path'] = page.url_path if page else self.request.path
|
||||||
self.request.session.modified = True
|
self.request.session.modified = True
|
||||||
else:
|
else:
|
||||||
visit_count.append({
|
visit_count.append({
|
||||||
'slug': page.slug,
|
'slug': page.slug,
|
||||||
'id': page.pk,
|
'id': page.pk,
|
||||||
'path': self.request.path,
|
'path': page.url_path if page else self.request.path,
|
||||||
'count': 1,
|
'count': 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -8,15 +8,11 @@ from django.contrib.auth import get_user_model
|
|||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from django.contrib.sessions.models import Session
|
from django.contrib.sessions.models import Session
|
||||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||||
from django.core.exceptions import ValidationError
|
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
from django.utils import timezone
|
|
||||||
from django.utils.lru_cache import lru_cache
|
from django.utils.lru_cache import lru_cache
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from wagtail.wagtailadmin.forms import WagtailAdminModelForm
|
from wagtail.wagtailadmin.forms import WagtailAdminModelForm
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SessionStore = import_module(settings.SESSION_ENGINE).SessionStore
|
SessionStore = import_module(settings.SESSION_ENGINE).SessionStore
|
||||||
|
|
||||||
|
|
||||||
@ -29,7 +25,6 @@ def user_from_data(user_id):
|
|||||||
return AnonymousUser()
|
return AnonymousUser()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SegmentAdminForm(WagtailAdminModelForm):
|
class SegmentAdminForm(WagtailAdminModelForm):
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super(SegmentAdminForm, self).clean()
|
cleaned_data = super(SegmentAdminForm, self).clean()
|
||||||
@ -62,7 +57,6 @@ class SegmentAdminForm(WagtailAdminModelForm):
|
|||||||
if field not in excluded:
|
if field not in excluded:
|
||||||
form.add_error(field, _('Cannot update a static segment'))
|
form.add_error(field, _('Cannot update a static segment'))
|
||||||
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
is_new = not self.instance.id
|
is_new = not self.instance.id
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
# Generated by Django 1.11.1 on 2017-05-31 14:28
|
# Generated by Django 1.11.1 on 2017-05-31 14:28
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.sessions.models import Session
|
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.template.defaultfilters import slugify
|
from django.template.defaultfilters import slugify
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
@ -11,11 +10,7 @@ from django.utils.safestring import mark_safe
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from modelcluster.models import ClusterableModel
|
from modelcluster.models import ClusterableModel
|
||||||
from wagtail.wagtailadmin.edit_handlers import (
|
from wagtail.wagtailadmin.edit_handlers import (
|
||||||
FieldPanel,
|
FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel)
|
||||||
FieldRowPanel,
|
|
||||||
InlinePanel,
|
|
||||||
MultiFieldPanel,
|
|
||||||
)
|
|
||||||
from wagtail.wagtailcore.models import Page
|
from wagtail.wagtailcore.models import Page
|
||||||
|
|
||||||
from wagtail_personalisation.rules import AbstractBaseRule
|
from wagtail_personalisation.rules import AbstractBaseRule
|
||||||
@ -125,7 +120,7 @@ class Segment(ClusterableModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def all_static(cls, rules):
|
def all_static(cls, rules):
|
||||||
return all(rule.static for rule in rules)
|
return all(rule.static for rule in rules)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def all_rules_static(self):
|
def all_rules_static(self):
|
||||||
|
@ -261,6 +261,7 @@ class QueryRule(AbstractBaseRule):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
icon = 'fa-link'
|
icon = 'fa-link'
|
||||||
|
static = True
|
||||||
|
|
||||||
parameter = models.SlugField(_("The query parameter to search for"),
|
parameter = models.SlugField(_("The query parameter to search for"),
|
||||||
max_length=20)
|
max_length=20)
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<div class="nice-padding block_container">
|
<div class="nice-padding block_container">
|
||||||
{% if all_count %}
|
{% if all_count %}
|
||||||
{% for segment in object_list %}
|
{% for segment in object_list %}
|
||||||
<div class="block block--{{ segment.status }}" onclick="location.href = 'edit/{{ segment.pk }}'">
|
<div class="block block--{{ segment.status }}" onclick="location.href = '{% url 'wagtail_personalisation_segment_modeladmin_edit' segment.pk %}'">
|
||||||
<h2>{{ segment }}</h2>
|
<h2>{{ segment }}</h2>
|
||||||
<div class="inspect_container">
|
<div class="inspect_container">
|
||||||
<ul class="inspect segment_stats">
|
<ul class="inspect segment_stats">
|
||||||
@ -90,7 +90,7 @@
|
|||||||
{% elif segment.status == segment.STATUS_ENABLED %}
|
{% elif segment.status == segment.STATUS_ENABLED %}
|
||||||
<li><a href="{% url 'segment:toggle' segment.pk %}" title="{% trans "Disable this segment" %}">disable</a></li>
|
<li><a href="{% url 'segment:toggle' segment.pk %}" title="{% trans "Disable this segment" %}">disable</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li><a href="edit/{{ segment.pk }}" title="{% trans "Configure this segment" %}">configure this</a></li>
|
<li><a href="{% url 'wagtail_personalisation_segment_modeladmin_edit' segment.pk %}" title="{% trans "Configure this segment" %}">configure this</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -103,9 +103,17 @@ def exclude_variants(pages):
|
|||||||
:return: List of pages that aren't variants
|
:return: List of pages that aren't variants
|
||||||
:rtype: list
|
:rtype: list
|
||||||
"""
|
"""
|
||||||
return [page for page in pages
|
return [
|
||||||
if (hasattr(page, 'personalisation_metadata') is False)
|
page for page in pages
|
||||||
or (hasattr(page, 'personalisation_metadata')
|
if (
|
||||||
and page.personalisation_metadata is None)
|
(
|
||||||
or (hasattr(page, 'personalisation_metadata')
|
hasattr(page, 'personalisation_metadata') is False
|
||||||
and page.personalisation_metadata.is_canonical)]
|
) or
|
||||||
|
(
|
||||||
|
hasattr(page, 'personalisation_metadata') and page.personalisation_metadata is None
|
||||||
|
) or
|
||||||
|
(
|
||||||
|
hasattr(page, 'personalisation_metadata') and page.personalisation_metadata.is_canonical
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
@ -7,7 +7,7 @@ from django.core.urlresolvers import reverse
|
|||||||
from django.template.defaultfilters import pluralize
|
from django.template.defaultfilters import pluralize
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from wagtail.wagtailadmin.site_summary import SummaryItem, PagesSummaryItem
|
from wagtail.wagtailadmin.site_summary import PagesSummaryItem, SummaryItem
|
||||||
from wagtail.wagtailadmin.widgets import Button, ButtonWithDropdownFromHook
|
from wagtail.wagtailadmin.widgets import Button, ButtonWithDropdownFromHook
|
||||||
from wagtail.wagtailcore import hooks
|
from wagtail.wagtailcore import hooks
|
||||||
from wagtail.wagtailcore.models import Page
|
from wagtail.wagtailcore.models import Page
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from pkg_resources import parse_version as V
|
|
||||||
|
|
||||||
import django
|
import django
|
||||||
|
from pkg_resources import parse_version as V
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
@ -56,6 +55,7 @@ TEMPLATES = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_middleware_settings():
|
def get_middleware_settings():
|
||||||
return (
|
return (
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
@ -69,6 +69,7 @@ def get_middleware_settings():
|
|||||||
'wagtail.wagtailcore.middleware.SiteMiddleware',
|
'wagtail.wagtailcore.middleware.SiteMiddleware',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Django 1.10 started to use "MIDDLEWARE" instead of "MIDDLEWARE_CLASSES".
|
# Django 1.10 started to use "MIDDLEWARE" instead of "MIDDLEWARE_CLASSES".
|
||||||
if V(django.get_version()) < V('1.10'):
|
if V(django.get_version()) < V('1.10'):
|
||||||
MIDDLEWARE_CLASSES = get_middleware_settings()
|
MIDDLEWARE_CLASSES = get_middleware_settings()
|
||||||
|
@ -21,7 +21,7 @@ class Migration(migrations.Migration):
|
|||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='ContentPage',
|
name='ContentPage',
|
||||||
fields=[
|
fields=[
|
||||||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), # noqa: E501
|
||||||
('subtitle', models.CharField(blank=True, default='', max_length=255)),
|
('subtitle', models.CharField(blank=True, default='', max_length=255)),
|
||||||
('body', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')),
|
('body', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')),
|
||||||
],
|
],
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
# Generated by Django 1.11.1 on 2017-06-02 04:26
|
# Generated by Django 1.11.1 on 2017-06-02 04:26
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
import wagtail.wagtailcore.fields
|
import wagtail.wagtailcore.fields
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@ -18,7 +18,7 @@ class Migration(migrations.Migration):
|
|||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='RegularPage',
|
name='RegularPage',
|
||||||
fields=[
|
fields=[
|
||||||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
|
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), # noqa: E501
|
||||||
('subtitle', models.CharField(blank=True, default='', max_length=255)),
|
('subtitle', models.CharField(blank=True, default='', max_length=255)),
|
||||||
('body', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')),
|
('body', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')),
|
||||||
],
|
],
|
||||||
|
@ -4,16 +4,14 @@ import datetime
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tests.factories.page import ContentPageFactory
|
from tests.factories.rule import ReferralRuleFactory, QueryRuleFactory
|
||||||
from tests.factories.rule import (
|
|
||||||
DayRuleFactory, DeviceRuleFactory, ReferralRuleFactory, TimeRuleFactory)
|
|
||||||
from tests.factories.segment import SegmentFactory
|
from tests.factories.segment import SegmentFactory
|
||||||
from tests.factories.site import SiteFactory
|
|
||||||
from wagtail_personalisation.models import Segment
|
from wagtail_personalisation.models import Segment
|
||||||
from wagtail_personalisation.rules import TimeRule
|
from wagtail_personalisation.rules import TimeRule
|
||||||
|
|
||||||
# Factory tests
|
# Factory tests
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_segment_create():
|
def test_segment_create():
|
||||||
factoried_segment = SegmentFactory()
|
factoried_segment = SegmentFactory()
|
||||||
@ -27,8 +25,6 @@ def test_segment_create():
|
|||||||
assert factoried_segment.status == segment.status
|
assert factoried_segment.status == segment.status
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_referral_rule_create():
|
def test_referral_rule_create():
|
||||||
segment = SegmentFactory(name='Referral')
|
segment = SegmentFactory(name='Referral')
|
||||||
@ -37,3 +33,16 @@ def test_referral_rule_create():
|
|||||||
segment=segment)
|
segment=segment)
|
||||||
|
|
||||||
assert referral_rule.regex_string == 'test.test'
|
assert referral_rule.regex_string == 'test.test'
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_query_rule_create():
|
||||||
|
segment = SegmentFactory(name='Query')
|
||||||
|
query_rule = QueryRuleFactory(
|
||||||
|
parameter="query",
|
||||||
|
value="value",
|
||||||
|
segment=segment)
|
||||||
|
|
||||||
|
assert query_rule.parameter == 'query'
|
||||||
|
assert query_rule.value == 'value'
|
||||||
|
assert query_rule.static
|
||||||
|
@ -16,6 +16,8 @@ def test_time_rule_create():
|
|||||||
segment=segment)
|
segment=segment)
|
||||||
|
|
||||||
assert time_rule.start_time == datetime.time(8, 0, 0)
|
assert time_rule.start_time == datetime.time(8, 0, 0)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
@freeze_time("10:00:00")
|
@freeze_time("10:00:00")
|
||||||
def test_requesttime_segment(client, site):
|
def test_requesttime_segment(client, site):
|
||||||
|
@ -2,15 +2,14 @@ from __future__ import absolute_import, unicode_literals
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from django.forms.models import model_to_dict
|
|
||||||
from django.contrib.sessions.backends.db import SessionStore
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from django.forms.models import model_to_dict
|
||||||
|
|
||||||
|
from tests.factories.segment import SegmentFactory
|
||||||
from wagtail_personalisation.forms import SegmentAdminForm
|
from wagtail_personalisation.forms import SegmentAdminForm
|
||||||
from wagtail_personalisation.models import Segment
|
from wagtail_personalisation.models import Segment
|
||||||
from wagtail_personalisation.rules import TimeRule, VisitCountRule
|
from wagtail_personalisation.rules import TimeRule, VisitCountRule
|
||||||
|
|
||||||
from tests.factories.segment import SegmentFactory
|
|
||||||
|
|
||||||
|
|
||||||
def form_with_data(segment, *rules):
|
def form_with_data(segment, *rules):
|
||||||
model_fields = ['type', 'status', 'count', 'name', 'match_any']
|
model_fields = ['type', 'status', 'count', 'name', 'match_any']
|
||||||
@ -63,6 +62,7 @@ def test_anonymous_user_not_added_to_static_segment_at_creation(site, client):
|
|||||||
|
|
||||||
assert not instance.static_users.all()
|
assert not instance.static_users.all()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_match_any_correct_populates(site, client, django_user_model):
|
def test_match_any_correct_populates(site, client, django_user_model):
|
||||||
user = django_user_model.objects.create(username='first')
|
user = django_user_model.objects.create(username='first')
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from wagtail_personalisation.utils import impersonate_other_page
|
from wagtail_personalisation.utils import (
|
||||||
|
exclude_variants, impersonate_other_page)
|
||||||
|
|
||||||
|
|
||||||
class Page(object):
|
class Page(object):
|
||||||
@ -19,3 +20,40 @@ def test_impersonate_other_page():
|
|||||||
impersonate_other_page(page, other_page)
|
impersonate_other_page(page, other_page)
|
||||||
|
|
||||||
assert page == other_page
|
assert page == other_page
|
||||||
|
|
||||||
|
|
||||||
|
class Metadata(object):
|
||||||
|
def __init__(self, is_canonical=True):
|
||||||
|
self.is_canonical = is_canonical
|
||||||
|
|
||||||
|
|
||||||
|
class PersonalisationMetadataPage(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.personalisation_metadata = Metadata()
|
||||||
|
|
||||||
|
|
||||||
|
def test_exclude_variants_includes_pages_with_no_metadata_property():
|
||||||
|
page = PersonalisationMetadataPage()
|
||||||
|
del page.personalisation_metadata
|
||||||
|
result = exclude_variants([page])
|
||||||
|
assert result == [page]
|
||||||
|
|
||||||
|
|
||||||
|
def test_exclude_variants_includes_pages_with_metadata_none():
|
||||||
|
page = PersonalisationMetadataPage()
|
||||||
|
page.personalisation_metadata = None
|
||||||
|
result = exclude_variants([page])
|
||||||
|
assert result == [page]
|
||||||
|
|
||||||
|
|
||||||
|
def test_exclude_variants_includes_pages_with_metadata_canonical():
|
||||||
|
page = PersonalisationMetadataPage()
|
||||||
|
result = exclude_variants([page])
|
||||||
|
assert result == [page]
|
||||||
|
|
||||||
|
|
||||||
|
def test_exclude_variants_excludes_pages_with_metadata_not_canonical():
|
||||||
|
page = PersonalisationMetadataPage()
|
||||||
|
page.personalisation_metadata.is_canonical = False
|
||||||
|
result = exclude_variants([page])
|
||||||
|
assert result == []
|
||||||
|
9
tox.ini
9
tox.ini
@ -1,13 +1,12 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py{27}-django{19}-wagtail{19},lint
|
envlist = py{27}-django{111}-wagtail{113},lint
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
commands = coverage run --parallel -m pytest {posargs}
|
commands = coverage run --parallel -m pytest {posargs}
|
||||||
extras = test
|
extras = test
|
||||||
deps =
|
deps =
|
||||||
django19: django>=1.9,<1.10
|
django111: django>=1.11,<1.12
|
||||||
wagtail19: wagtail>=1.9,<1.10
|
wagtail19: wagtail>=1.13,<1.14
|
||||||
wagtail110: wagtail>=1.10,<1.11
|
|
||||||
|
|
||||||
[testenv:coverage-report]
|
[testenv:coverage-report]
|
||||||
basepython = python2.7
|
basepython = python2.7
|
||||||
@ -21,7 +20,7 @@ commands =
|
|||||||
|
|
||||||
[testenv:lint]
|
[testenv:lint]
|
||||||
basepython = python2.7
|
basepython = python2.7
|
||||||
deps = flake8
|
deps = flake8==3.5.0
|
||||||
commands =
|
commands =
|
||||||
flake8 src tests setup.py
|
flake8 src tests setup.py
|
||||||
isort -q --recursive --diff src/ tests/
|
isort -q --recursive --diff src/ tests/
|
||||||
|
Reference in New Issue
Block a user