From cbe34dc8ecbd42de6db5caa9fa66b04fa4841636 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 10 Sep 2020 13:09:08 +0200 Subject: [PATCH] Refs #31993 -- Added more titles assertions for admin views. --- tests/admin_views/tests.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 7c4474d3dc..62aa236e2b 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1726,6 +1726,8 @@ class AdminViewPermissionsTest(TestCase): # Now give the user permission to add but not change. self.viewuser.user_permissions.add(get_perm(Article, get_permission_codename('add', Article._meta))) response = self.client.get(reverse('admin:admin_views_article_add')) + self.assertEqual(response.context['title'], 'Add article') + self.assertContains(response, 'Add article | Django site admin') self.assertContains(response, '') post = self.client.post(reverse('admin:admin_views_article_add'), add_dict, follow=False) self.assertEqual(post.status_code, 302) @@ -1824,11 +1826,16 @@ class AdminViewPermissionsTest(TestCase): # view user can view articles but not make changes. self.client.force_login(self.viewuser) response = self.client.get(article_changelist_url) - self.assertEqual(response.status_code, 200) self.assertEqual(response.context['title'], 'Select article to view') + self.assertContains( + response, + 'Select article to view | Django site admin', + ) + self.assertContains(response, '

Select article to view

') response = self.client.get(article_change_url) - self.assertEqual(response.status_code, 200) self.assertEqual(response.context['title'], 'View article') + self.assertContains(response, 'View article | Django site admin') + self.assertContains(response, '

View article

') self.assertContains(response, '') self.assertContains(response, 'Close') post = self.client.post(article_change_url, change_dict) @@ -1839,11 +1846,19 @@ class AdminViewPermissionsTest(TestCase): # change user can view all items and edit them self.client.force_login(self.changeuser) response = self.client.get(article_changelist_url) - self.assertEqual(response.status_code, 200) self.assertEqual(response.context['title'], 'Select article to change') + self.assertContains( + response, + 'Select article to change | Django site admin', + ) + self.assertContains(response, '

Select article to change

') response = self.client.get(article_change_url) - self.assertEqual(response.status_code, 200) self.assertEqual(response.context['title'], 'Change article') + self.assertContains( + response, + 'Change article | Django site admin', + ) + self.assertContains(response, '

Change article

') post = self.client.post(article_change_url, change_dict) self.assertRedirects(post, article_changelist_url) self.assertEqual(Article.objects.get(pk=self.a1.pk).content, '

edited article

') @@ -1923,8 +1938,9 @@ class AdminViewPermissionsTest(TestCase): change_url = reverse('admin9:admin_views_article_change', args=(self.a1.pk,)) self.client.force_login(self.viewuser) response = self.client.get(change_url) - self.assertEqual(response.status_code, 200) self.assertEqual(response.context['title'], 'View article') + self.assertContains(response, 'View article | Django site admin') + self.assertContains(response, '

View article

') self.assertContains(response, 'Close') def test_change_view_save_as_new(self):