mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-19 20:41:56 +00:00
Tests updated
This commit is contained in:
parent
b10fd60f1b
commit
e8510af03a
5 changed files with 89 additions and 3 deletions
|
|
@ -86,6 +86,41 @@
|
|||
}
|
||||
},
|
||||
|
||||
{
|
||||
"pk": 13,
|
||||
"model": "wagtailcore.page",
|
||||
"fields": {
|
||||
"title": "Saint Patrick",
|
||||
"numchild": 0,
|
||||
"show_in_menus": true,
|
||||
"live": true,
|
||||
"depth": 4,
|
||||
"content_type": ["tests", "singleeventpage"],
|
||||
"path": "0001000100010005",
|
||||
"url_path": "/home/events/saint-patrick/",
|
||||
"slug": "saint-patrick",
|
||||
"owner": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 13,
|
||||
"model": "tests.eventpage",
|
||||
"fields": {
|
||||
"date_from": "2014-12-25",
|
||||
"audience": "private",
|
||||
"location": "Wellington",
|
||||
"body": "<p>The day when nothing makes sense.</p>",
|
||||
"cost": "Semi-free"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 13,
|
||||
"model": "tests.singleeventpage",
|
||||
"fields": {
|
||||
"excerpt": "A little tiny excerpt for Saint Patrick."
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"pk": 1,
|
||||
"model": "tests.eventpagespeaker",
|
||||
|
|
|
|||
22
wagtail/tests/testapp/migrations/0007_singleeventpage.py
Normal file
22
wagtail/tests/testapp/migrations/0007_singleeventpage.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tests', '0006_image_file_size'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SingleEventPage',
|
||||
fields=[
|
||||
('eventpage_ptr', models.OneToOneField(auto_created=True, to='tests.EventPage', serialize=False, parent_link=True, primary_key=True)),
|
||||
('excerpt', models.TextField(help_text='Short text to describe what is this action about', max_length=255, null=True, blank=True)),
|
||||
],
|
||||
bases=('tests.eventpage',),
|
||||
),
|
||||
]
|
||||
|
|
@ -216,6 +216,13 @@ EventPage.promote_panels = [
|
|||
]
|
||||
|
||||
|
||||
# Just to be able to test multi table inheritance
|
||||
class SingleEventPage(EventPage):
|
||||
excerpt = models.TextField(max_length=255, blank=True, null=True, help_text="Short text to describe what is this action about")
|
||||
|
||||
SingleEventPage.content_panels = [FieldPanel('excerpt')] + EventPage.content_panels
|
||||
|
||||
|
||||
# Event index (has a separate AJAX template, and a custom template context)
|
||||
class EventIndex(Page):
|
||||
intro = RichTextField(blank=True)
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class TestFixTreeCommand(TestCase):
|
|||
# Check that the issues were detected
|
||||
output_string = output.read()
|
||||
self.assertIn("Incorrect numchild value found for pages: [2]", output_string)
|
||||
self.assertIn("Orphaned pages found: [4, 5, 6, 9]", output_string)
|
||||
self.assertIn("Orphaned pages found: [4, 5, 6, 9, 13]", output_string)
|
||||
|
||||
# Check that christmas_page is still in the tree
|
||||
self.assertTrue(Page.objects.filter(id=christmas_page.id).exists())
|
||||
|
|
@ -102,7 +102,7 @@ class TestFixTreeCommand(TestCase):
|
|||
# Check that the issues were detected
|
||||
output_string = output.read()
|
||||
self.assertIn("Incorrect numchild value found for pages: [2]", output_string)
|
||||
self.assertIn("4 orphaned pages deleted.", output_string)
|
||||
self.assertIn("5 orphaned pages deleted.", output_string)
|
||||
|
||||
# Check that christmas_page has been deleted
|
||||
self.assertFalse(Page.objects.filter(id=christmas_page.id).exists())
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from django.contrib.auth import get_user_model
|
|||
from django.contrib.auth.models import AnonymousUser
|
||||
|
||||
from wagtail.wagtailcore.models import Page, Site
|
||||
from wagtail.tests.testapp.models import EventPage, EventIndex, SimplePage, BusinessIndex, BusinessSubIndex, BusinessChild, StandardIndex
|
||||
from wagtail.tests.testapp.models import SingleEventPage, EventPage, EventIndex, SimplePage, BusinessIndex, BusinessSubIndex, BusinessChild, StandardIndex
|
||||
|
||||
|
||||
class TestSiteRouting(TestCase):
|
||||
|
|
@ -604,6 +604,28 @@ class TestCopyPage(TestCase):
|
|||
# Check that the user on the last revision is correct
|
||||
self.assertEqual(new_christmas_event.get_latest_revision().user, event_moderator)
|
||||
|
||||
def test_copy_multi_table_inheritance(self):
|
||||
saint_patrick_event = SingleEventPage.objects.get(url_path='/home/events/saint-patrick/')
|
||||
|
||||
# Copy it
|
||||
new_saint_patrick_event = saint_patrick_event.copy(update_attrs={'slug': 'new-saint-patrick'})
|
||||
|
||||
# Check that new_saint_patrick_event is correct
|
||||
self.assertIsInstance(new_saint_patrick_event, SingleEventPage)
|
||||
self.assertEqual(new_saint_patrick_event.excerpt, saint_patrick_event.excerpt)
|
||||
|
||||
# Check that new_saint_patrick_event is a different page, including parents from both EventPage and Page
|
||||
self.assertNotEqual(saint_patrick_event.id, new_saint_patrick_event.id)
|
||||
self.assertNotEqual(saint_patrick_event.eventpage_ptr.id, new_saint_patrick_event.eventpage_ptr.id)
|
||||
self.assertNotEqual(saint_patrick_event.eventpage_ptr.page_ptr.id, new_saint_patrick_event.eventpage_ptr.page_ptr.id)
|
||||
|
||||
# Check that the url path was updated
|
||||
self.assertEqual(new_saint_patrick_event.url_path, '/home/events/new-saint-patrick/')
|
||||
|
||||
# Check that both parent instance exists
|
||||
self.assertIsInstance(EventPage.objects.get(id=new_saint_patrick_event.id), EventPage)
|
||||
self.assertIsInstance(Page.objects.get(id=new_saint_patrick_event.id), Page)
|
||||
|
||||
|
||||
class TestSubpageTypeBusinessRules(TestCase):
|
||||
def test_allowed_subpage_types(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue