Skip to content

Commit

Permalink
Refs #31993 -- Added more titles assertions for admin views.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdufresne authored and felixxm committed Sep 10, 2020
1 parent 53c0d16 commit cbe34dc
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions tests/admin_views/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,8 @@ def test_add_view(self):
# 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, '<title>Add article | Django site admin</title>')
self.assertContains(response, '<input type="submit" value="Save and view" name="_continue">')
post = self.client.post(reverse('admin:admin_views_article_add'), add_dict, follow=False)
self.assertEqual(post.status_code, 302)
Expand Down Expand Up @@ -1824,11 +1826,16 @@ def test_change_view(self):
# 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,
'<title>Select article to view | Django site admin</title>',
)
self.assertContains(response, '<h1>Select article to view</h1>')
response = self.client.get(article_change_url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['title'], 'View article')
self.assertContains(response, '<title>View article | Django site admin</title>')
self.assertContains(response, '<h1>View article</h1>')
self.assertContains(response, '<label>Extra form field:</label>')
self.assertContains(response, '<a href="/test_admin/admin/admin_views/article/" class="closelink">Close</a>')
post = self.client.post(article_change_url, change_dict)
Expand All @@ -1839,11 +1846,19 @@ def test_change_view(self):
# 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,
'<title>Select article to change | Django site admin</title>',
)
self.assertContains(response, '<h1>Select article to change</h1>')
response = self.client.get(article_change_url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['title'], 'Change article')
self.assertContains(
response,
'<title>Change article | Django site admin</title>',
)
self.assertContains(response, '<h1>Change article</h1>')
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, '<p>edited article</p>')
Expand Down Expand Up @@ -1923,8 +1938,9 @@ def test_change_view_without_object_change_permission(self):
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, '<title>View article | Django site admin</title>')
self.assertContains(response, '<h1>View article</h1>')
self.assertContains(response, '<a href="/test_admin/admin9/admin_views/article/" class="closelink">Close</a>')

def test_change_view_save_as_new(self):
Expand Down

0 comments on commit cbe34dc

Please sign in to comment.