diff --git a/wagtail/contrib/wagtailroutablepage/tests.py b/wagtail/contrib/wagtailroutablepage/tests.py index 2e24cb3fe1..2226b5cb54 100644 --- a/wagtail/contrib/wagtailroutablepage/tests.py +++ b/wagtail/contrib/wagtailroutablepage/tests.py @@ -1,7 +1,7 @@ from django.test import TestCase, RequestFactory from wagtail.wagtailcore.models import Page, Site -from wagtail.tests.testapp.models import RoutablePageTest, routable_page_external_view +from wagtail.tests.routablepage.models import RoutablePageTest, routable_page_external_view from wagtail.contrib.wagtailroutablepage.templatetags.wagtailroutablepage_tags import routablepageurl diff --git a/wagtail/tests/routablepage/__init__.py b/wagtail/tests/routablepage/__init__.py new file mode 100644 index 0000000000..87fe2ba4a4 --- /dev/null +++ b/wagtail/tests/routablepage/__init__.py @@ -0,0 +1 @@ +default_app_config = 'wagtail.tests.routablepage.apps.WagtailRoutablePageTestsAppConfig' diff --git a/wagtail/tests/routablepage/apps.py b/wagtail/tests/routablepage/apps.py new file mode 100644 index 0000000000..8a9f69be87 --- /dev/null +++ b/wagtail/tests/routablepage/apps.py @@ -0,0 +1,7 @@ +from django.apps import AppConfig + + +class WagtailRoutablePageTestsAppConfig(AppConfig): + name = 'wagtail.tests.routablepage' + label = 'routablepagetests' + verbose_name = "Wagtail routable page tests" diff --git a/wagtail/tests/routablepage/migrations/0001_initial.py b/wagtail/tests/routablepage/migrations/0001_initial.py new file mode 100644 index 0000000000..6d5bdfa870 --- /dev/null +++ b/wagtail/tests/routablepage/migrations/0001_initial.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import wagtail.contrib.wagtailroutablepage.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0013_update_golive_expire_help_text'), + ] + + operations = [ + migrations.CreateModel( + name='RoutablePageTest', + fields=[ + ('page_ptr', models.OneToOneField(to='wagtailcore.Page', serialize=False, auto_created=True, primary_key=True, parent_link=True)), + ], + options={ + 'abstract': False, + }, + bases=(wagtail.contrib.wagtailroutablepage.models.RoutablePageMixin, 'wagtailcore.page'), + ), + ] diff --git a/wagtail/tests/routablepage/migrations/__init__.py b/wagtail/tests/routablepage/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/wagtail/tests/routablepage/models.py b/wagtail/tests/routablepage/models.py new file mode 100644 index 0000000000..51aee5b673 --- /dev/null +++ b/wagtail/tests/routablepage/models.py @@ -0,0 +1,26 @@ +from django.db import models +from django.http import HttpResponse +from django.conf.urls import url + +from wagtail.contrib.wagtailroutablepage.models import RoutablePage + + +def routable_page_external_view(request, arg): + return HttpResponse("EXTERNAL VIEW: " + arg) + +class RoutablePageTest(RoutablePage): + subpage_urls = ( + url(r'^$', 'main', name='main'), + url(r'^archive/year/(\d+)/$', 'archive_by_year', name='archive_by_year'), + url(r'^archive/author/(?P.+)/$', 'archive_by_author', name='archive_by_author'), + url(r'^external/(.+)/$', routable_page_external_view, name='external_view') + ) + + def archive_by_year(self, request, year): + return HttpResponse("ARCHIVE BY YEAR: " + str(year)) + + def archive_by_author(self, request, author_slug): + return HttpResponse("ARCHIVE BY AUTHOR: " + author_slug) + + def main(self, request): + return HttpResponse("MAIN VIEW") diff --git a/wagtail/tests/settings.py b/wagtail/tests/settings.py index 5ac3189a01..04d692151c 100644 --- a/wagtail/tests/settings.py +++ b/wagtail/tests/settings.py @@ -79,6 +79,7 @@ INSTALLED_APPS = ( 'wagtail.tests.testapp', 'wagtail.tests.customuser', 'wagtail.tests.snippets', + 'wagtail.tests.routablepage', # Install wagtailredirects with its appconfig # Theres nothing special about wagtailredirects, we just need to have one diff --git a/wagtail/tests/testapp/migrations/0013_auto_20150330_0717.py b/wagtail/tests/testapp/migrations/0013_auto_20150330_0717.py new file mode 100644 index 0000000000..8f27b4439a --- /dev/null +++ b/wagtail/tests/testapp/migrations/0013_auto_20150330_0717.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0013_update_golive_expire_help_text'), + ('wagtailforms', '0001_initial'), + ('wagtailredirects', '0001_initial'), + ('wagtailsearch', '0001_initial'), + ('tests', '0012_auto_20150330_0709'), + ] + + operations = [ + migrations.DeleteModel( + name='RoutablePageTest', + ), + ] diff --git a/wagtail/tests/testapp/models.py b/wagtail/tests/testapp/models.py index a13f83752c..c2bea54ae0 100644 --- a/wagtail/tests/testapp/models.py +++ b/wagtail/tests/testapp/models.py @@ -3,8 +3,6 @@ from __future__ import unicode_literals from django.db import models from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.utils.encoding import python_2_unicode_compatible -from django.conf.urls import url -from django.http import HttpResponse from taggit.models import TaggedItemBase @@ -20,7 +18,6 @@ from wagtail.wagtailsnippets.models import register_snippet from wagtail.wagtailforms.models import AbstractEmailForm, AbstractFormField from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel from wagtail.wagtailsearch import index -from wagtail.contrib.wagtailroutablepage.models import RoutablePage from wagtail.wagtailimages.models import AbstractImage, Image @@ -414,27 +411,6 @@ class SearchTestChild(SearchTest): ] -def routable_page_external_view(request, arg): - return HttpResponse("EXTERNAL VIEW: " + arg) - -class RoutablePageTest(RoutablePage): - subpage_urls = ( - url(r'^$', 'main', name='main'), - url(r'^archive/year/(\d+)/$', 'archive_by_year', name='archive_by_year'), - url(r'^archive/author/(?P.+)/$', 'archive_by_author', name='archive_by_author'), - url(r'^external/(.+)/$', routable_page_external_view, name='external_view') - ) - - def archive_by_year(self, request, year): - return HttpResponse("ARCHIVE BY YEAR: " + str(year)) - - def archive_by_author(self, request, author_slug): - return HttpResponse("ARCHIVE BY AUTHOR: " + author_slug) - - def main(self, request): - return HttpResponse("MAIN VIEW") - - class TaggedPageTag(TaggedItemBase): content_object = ParentalKey('tests.TaggedPage', related_name='tagged_items')