0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-30 01:46:24 +01:00

Add test for button URLs including a 'next' parameter

This commit is contained in:
Matt Westcott 2020-07-14 11:59:48 +01:00
parent d75ab584c7
commit 31a9b285a0

View File

@ -1,6 +1,8 @@
from django.test import TestCase
from django.urls import reverse
from django.utils.http import urlencode
from wagtail.tests.testapp.models import EventPage
from wagtail.tests.utils import WagtailTestUtils
@ -9,12 +11,21 @@ class TestContentTypeUse(TestCase, WagtailTestUtils):
def setUp(self):
self.user = self.login()
self.christmas_page = EventPage.objects.get(title="Christmas")
def test_content_type_use(self):
# Get use of event page
response = self.client.get(reverse('wagtailadmin_pages:type_use', args=('tests', 'eventpage')))
request_url = reverse('wagtailadmin_pages:type_use', args=('tests', 'eventpage'))
response = self.client.get(request_url)
# Check response
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailadmin/pages/content_type_use.html')
self.assertContains(response, "Christmas")
# Links to 'delete' etc should include a 'next' URL parameter pointing back here
delete_url = (
reverse('wagtailadmin_pages:delete', args=(self.christmas_page.id,))
+ '?' + urlencode({'next': request_url})
)
self.assertContains(response, delete_url)