mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Write a failing test for missing page model
This commit is contained in:
parent
ac84cea671
commit
d33a00aa49
@ -1,7 +1,8 @@
|
||||
import collections
|
||||
import json
|
||||
|
||||
import mock
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
@ -79,6 +80,17 @@ class TestPageListing(TestCase):
|
||||
response = self.get_response()
|
||||
content = json.loads(response.content.decode('UTF-8'))
|
||||
self.assertEqual(content['meta']['total_count'], new_total_count)
|
||||
|
||||
def test_page_listing_with_missing_page_model(self):
|
||||
# Create a ContentType that doesn't correspond to a real model
|
||||
missing_page_content_type = ContentType.objects.create(app_label='tests', model='missingpage')
|
||||
|
||||
# Turn a BlogEntryPage into this
|
||||
models.BlogEntryPage.objects.filter(id=16).update(content_type=missing_page_content_type)
|
||||
|
||||
# get page listing with missing model
|
||||
response = self.get_response()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# TYPE FILTER
|
||||
|
||||
@ -904,6 +916,17 @@ class TestPageDetail(TestCase):
|
||||
|
||||
self.assertIn('related_links', content)
|
||||
self.assertEqual(content['feed_image'], None)
|
||||
|
||||
def test_page_with_missing_page_model(self):
|
||||
# Create a ContentType that doesn't correspond to a real model
|
||||
missing_page_content_type = ContentType.objects.create(app_label='tests', model='missingpage')
|
||||
|
||||
# Turn a BlogEntryPage into this
|
||||
models.BlogEntryPage.objects.filter(id=16).update(content_type=missing_page_content_type)
|
||||
|
||||
# get missing model page
|
||||
response = self.get_response(16)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# FIELDS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user