0
0
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:
Abdulmalik Abdulwahab 2018-06-21 09:44:06 +01:00
parent ac84cea671
commit d33a00aa49

View File

@ -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