Refactor the test structure
This renames the tests.sandbox app to tests.site to clear up some confusion with the two sandbox app's.
This commit is contained in:
@ -160,6 +160,3 @@ texinfo_documents = [
|
|||||||
author, 'wagtail-personalisation', 'One line description of project.',
|
author, 'wagtail-personalisation', 'One line description of project.',
|
||||||
'Miscellaneous'),
|
'Miscellaneous'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
22
manage.py
22
manage.py
@ -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)
|
|
@ -1,6 +1,10 @@
|
|||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
DJANGO_SETTINGS_MODULE = tests.sandbox.settings
|
DJANGO_SETTINGS_MODULE = tests.settings
|
||||||
norecursedirs = .tox .git
|
minversion = 3.0
|
||||||
|
strict = true
|
||||||
|
django_find_project = false
|
||||||
|
testpaths = tests
|
||||||
|
python_paths = .
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore=E731
|
ignore=E731
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from wagtail.wagtailcore.models import Page, Site
|
|
||||||
|
|
||||||
pytest_plugins = [
|
pytest_plugins = [
|
||||||
'tests.fixtures'
|
'tests.fixtures'
|
||||||
@ -10,7 +9,9 @@ pytest_plugins = [
|
|||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def django_db_setup(django_db_setup, django_db_blocker):
|
def django_db_setup(django_db_setup, django_db_blocker):
|
||||||
|
from wagtail.wagtailcore.models import Page, Site
|
||||||
|
|
||||||
with django_db_blocker.unblock():
|
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()
|
Site.objects.all().delete()
|
||||||
Page.objects.all().exclude(depth=1).delete()
|
Page.objects.all().exclude(depth=1).delete()
|
||||||
|
@ -4,7 +4,7 @@ import factory
|
|||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
from wagtail_factories.factories import MP_NodeFactory
|
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):
|
class HomePageFactory(MP_NodeFactory):
|
||||||
|
@ -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),
|
|
||||||
),
|
|
||||||
]
|
|
@ -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',
|
|
||||||
),
|
|
||||||
]
|
|
@ -21,7 +21,7 @@ CACHES = {
|
|||||||
SECRET_KEY = 'not needed'
|
SECRET_KEY = 'not needed'
|
||||||
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
|
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
|
||||||
|
|
||||||
ROOT_URLCONF = 'tests.sandbox.urls'
|
ROOT_URLCONF = 'tests.site.urls'
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
@ -31,12 +31,12 @@ STATICFILES_FINDERS = (
|
|||||||
|
|
||||||
USE_TZ = False
|
USE_TZ = False
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
TESTS_ROOT = os.path.dirname(os.path.abspath(__file__))
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [
|
'DIRS': [
|
||||||
os.path.join(BASE_DIR, 'templates'),
|
os.path.join(TESTS_ROOT, 'site', 'templates'),
|
||||||
],
|
],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
@ -66,7 +66,6 @@ MIDDLEWARE = (
|
|||||||
|
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
'wagtail_personalisation',
|
'wagtail_personalisation',
|
||||||
'tests.sandbox.pages',
|
|
||||||
|
|
||||||
'wagtail.contrib.modeladmin',
|
'wagtail.contrib.modeladmin',
|
||||||
'wagtail.wagtailsearch',
|
'wagtail.wagtailsearch',
|
||||||
@ -85,6 +84,8 @@ INSTALLED_APPS = (
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
|
||||||
|
'tests.site.pages',
|
||||||
)
|
)
|
||||||
|
|
||||||
PASSWORD_HASHERS = (
|
PASSWORD_HASHERS = (
|
@ -1,40 +1,45 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- 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 __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
import wagtail.wagtailcore.fields
|
import wagtail.wagtailcore.fields
|
||||||
|
import wagtail_personalisation.models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('wagtail_personalisation', '0009_auto_20170531_0428'),
|
|
||||||
('wagtailcore', '0033_remove_golive_expiry_help_text'),
|
('wagtailcore', '0033_remove_golive_expiry_help_text'),
|
||||||
('pages', '0001_initial'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='SpecialPage',
|
name='HomePage',
|
||||||
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')),
|
||||||
('is_segmented', models.BooleanField(default=False)),
|
|
||||||
('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='')),
|
||||||
('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={
|
options={
|
||||||
'abstract': False,
|
'abstract': False,
|
||||||
},
|
},
|
||||||
bases=('wagtailcore.page', models.Model),
|
bases=(wagtail_personalisation.models.PersonalisablePageMixin, 'wagtailcore.page'),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.CreateModel(
|
||||||
model_name='homepage',
|
name='SpecialPage',
|
||||||
name='segment',
|
fields=[
|
||||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtail_personalisation.Segment'),
|
('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'),
|
||||||
),
|
),
|
||||||
]
|
]
|
Reference in New Issue
Block a user