diff --git a/docs/conf.py b/docs/conf.py index cb0534a..b3b8b53 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -160,6 +160,3 @@ texinfo_documents = [ author, 'wagtail-personalisation', 'One line description of project.', 'Miscellaneous'), ] - - - diff --git a/manage.py b/manage.py deleted file mode 100755 index 3c54ca4..0000000 --- a/manage.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python -import os -import sys - -if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.sandbox.settings") - try: - from django.core.management import execute_from_command_line - except ImportError: - # The above import may fail for some other reason. Ensure that the - # issue is really that Django is missing to avoid masking other - # exceptions on Python 2. - try: - import django - except ImportError: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) - raise - execute_from_command_line(sys.argv) diff --git a/setup.cfg b/setup.cfg index bbc85bd..471f464 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,10 @@ [tool:pytest] -DJANGO_SETTINGS_MODULE = tests.sandbox.settings -norecursedirs = .tox .git +DJANGO_SETTINGS_MODULE = tests.settings +minversion = 3.0 +strict = true +django_find_project = false +testpaths = tests +python_paths = . [flake8] ignore=E731 diff --git a/tests/conftest.py b/tests/conftest.py index 8942e2e..ee60a76 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,6 @@ from __future__ import absolute_import, unicode_literals import pytest -from wagtail.wagtailcore.models import Page, Site pytest_plugins = [ 'tests.fixtures' @@ -10,7 +9,9 @@ pytest_plugins = [ @pytest.fixture(scope='session') def django_db_setup(django_db_setup, django_db_blocker): + from wagtail.wagtailcore.models import Page, Site + with django_db_blocker.unblock(): - # Remove some initial data that is brought by the sandbox module + # Remove some initial data that is brought by the tests.site module Site.objects.all().delete() Page.objects.all().exclude(depth=1).delete() diff --git a/tests/factories/page.py b/tests/factories/page.py index 1e0da39..bb14c12 100644 --- a/tests/factories/page.py +++ b/tests/factories/page.py @@ -4,7 +4,7 @@ import factory from django.utils.text import slugify from wagtail_factories.factories import MP_NodeFactory -from tests.sandbox.pages.models import HomePage, SpecialPage +from tests.site.pages.models import HomePage, SpecialPage class HomePageFactory(MP_NodeFactory): diff --git a/tests/sandbox/pages/migrations/0001_initial.py b/tests/sandbox/pages/migrations/0001_initial.py deleted file mode 100644 index 86ff359..0000000 --- a/tests/sandbox/pages/migrations/0001_initial.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.1 on 2017-05-31 06:40 -from __future__ import unicode_literals - -import django.db.models.deletion -import wagtail.wagtailcore.fields -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('wagtail_personalisation', '0009_auto_20170531_0428'), - ] - - operations = [ - migrations.CreateModel( - name='HomePage', - 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')), - ('is_segmented', models.BooleanField(default=False)), - ('subtitle', models.CharField(blank=True, default='', max_length=255)), - ('body', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')), - ('canonical_page', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='variations', to='pages.HomePage')), - ('segment', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='segments', to='wagtail_personalisation.Segment')), - ], - options={ - 'abstract': False, - }, - bases=('wagtailcore.page', models.Model), - ), - ] diff --git a/tests/sandbox/pages/migrations/0003_auto_20170531_1428.py b/tests/sandbox/pages/migrations/0003_auto_20170531_1428.py deleted file mode 100644 index 10c185b..0000000 --- a/tests/sandbox/pages/migrations/0003_auto_20170531_1428.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.1 on 2017-05-31 14:28 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('pages', '0002_auto_20170531_0915'), - ] - - operations = [ - migrations.RemoveField( - model_name='homepage', - name='canonical_page', - ), - migrations.RemoveField( - model_name='homepage', - name='is_segmented', - ), - migrations.RemoveField( - model_name='homepage', - name='segment', - ), - migrations.RemoveField( - model_name='specialpage', - name='canonical_page', - ), - migrations.RemoveField( - model_name='specialpage', - name='is_segmented', - ), - migrations.RemoveField( - model_name='specialpage', - name='segment', - ), - ] diff --git a/tests/sandbox/settings.py b/tests/settings.py similarity index 93% rename from tests/sandbox/settings.py rename to tests/settings.py index a8aff38..c892786 100644 --- a/tests/sandbox/settings.py +++ b/tests/settings.py @@ -21,7 +21,7 @@ CACHES = { SECRET_KEY = 'not needed' SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' -ROOT_URLCONF = 'tests.sandbox.urls' +ROOT_URLCONF = 'tests.site.urls' STATIC_URL = '/static/' @@ -31,12 +31,12 @@ STATICFILES_FINDERS = ( USE_TZ = False -BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +TESTS_ROOT = os.path.dirname(os.path.abspath(__file__)) TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ - os.path.join(BASE_DIR, 'templates'), + os.path.join(TESTS_ROOT, 'site', 'templates'), ], 'APP_DIRS': True, 'OPTIONS': { @@ -66,7 +66,6 @@ MIDDLEWARE = ( INSTALLED_APPS = ( 'wagtail_personalisation', - 'tests.sandbox.pages', 'wagtail.contrib.modeladmin', 'wagtail.wagtailsearch', @@ -85,6 +84,8 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + + 'tests.site.pages', ) PASSWORD_HASHERS = ( diff --git a/tests/sandbox/__init__.py b/tests/site/__init__.py similarity index 100% rename from tests/sandbox/__init__.py rename to tests/site/__init__.py diff --git a/tests/sandbox/pages/__init__.py b/tests/site/pages/__init__.py similarity index 100% rename from tests/sandbox/pages/__init__.py rename to tests/site/pages/__init__.py diff --git a/tests/sandbox/pages/migrations/0002_auto_20170531_0915.py b/tests/site/pages/migrations/0001_initial.py similarity index 53% rename from tests/sandbox/pages/migrations/0002_auto_20170531_0915.py rename to tests/site/pages/migrations/0001_initial.py index 8fefbda..01176f8 100644 --- a/tests/sandbox/pages/migrations/0002_auto_20170531_0915.py +++ b/tests/site/pages/migrations/0001_initial.py @@ -1,40 +1,45 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.11.1 on 2017-05-31 09:15 +# Generated by Django 1.11.1 on 2017-06-02 02:21 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion import wagtail.wagtailcore.fields +import wagtail_personalisation.models class Migration(migrations.Migration): + initial = True + dependencies = [ - ('wagtail_personalisation', '0009_auto_20170531_0428'), ('wagtailcore', '0033_remove_golive_expiry_help_text'), - ('pages', '0001_initial'), ] operations = [ migrations.CreateModel( - name='SpecialPage', + name='HomePage', 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')), - ('is_segmented', models.BooleanField(default=False)), ('subtitle', models.CharField(blank=True, default='', max_length=255)), ('body', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')), - ('special', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')), - ('canonical_page', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='variations', to='pages.SpecialPage')), - ('segment', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtail_personalisation.Segment')), ], options={ 'abstract': False, }, - bases=('wagtailcore.page', models.Model), + bases=(wagtail_personalisation.models.PersonalisablePageMixin, 'wagtailcore.page'), ), - migrations.AlterField( - model_name='homepage', - name='segment', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtail_personalisation.Segment'), + migrations.CreateModel( + name='SpecialPage', + 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')), + ('subtitle', models.CharField(blank=True, default='', max_length=255)), + ('body', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')), + ('special', wagtail.wagtailcore.fields.RichTextField(blank=True, default='')), + ], + options={ + 'abstract': False, + }, + bases=(wagtail_personalisation.models.PersonalisablePageMixin, 'wagtailcore.page'), ), ] diff --git a/tests/sandbox/pages/migrations/__init__.py b/tests/site/pages/migrations/__init__.py similarity index 100% rename from tests/sandbox/pages/migrations/__init__.py rename to tests/site/pages/migrations/__init__.py diff --git a/tests/sandbox/pages/models.py b/tests/site/pages/models.py similarity index 100% rename from tests/sandbox/pages/models.py rename to tests/site/pages/models.py diff --git a/tests/sandbox/templates/404.html b/tests/site/templates/404.html similarity index 100% rename from tests/sandbox/templates/404.html rename to tests/site/templates/404.html diff --git a/tests/sandbox/templates/500.html b/tests/site/templates/500.html similarity index 100% rename from tests/sandbox/templates/500.html rename to tests/site/templates/500.html diff --git a/tests/sandbox/templates/base.html b/tests/site/templates/base.html similarity index 100% rename from tests/sandbox/templates/base.html rename to tests/site/templates/base.html diff --git a/tests/sandbox/templates/pages/home_page.html b/tests/site/templates/pages/home_page.html similarity index 100% rename from tests/sandbox/templates/pages/home_page.html rename to tests/site/templates/pages/home_page.html diff --git a/tests/sandbox/urls.py b/tests/site/urls.py similarity index 100% rename from tests/sandbox/urls.py rename to tests/site/urls.py