Add admin test for publish view
This commit is contained in:
parent
1b42655d97
commit
094525326f
1 changed files with 24 additions and 0 deletions
|
@ -34,6 +34,8 @@ class AdminTest(BaseTest):
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
def test_admin_post_views(self):
|
def test_admin_post_views(self):
|
||||||
|
self.get_pages()
|
||||||
|
|
||||||
post_admin = admin.site._registry[Post]
|
post_admin = admin.site._registry[Post]
|
||||||
request = self.get_page_request('/', self.user, r'/en/blog/', edit=False)
|
request = self.get_page_request('/', self.user, r'/en/blog/', edit=False)
|
||||||
|
|
||||||
|
@ -50,6 +52,28 @@ class AdminTest(BaseTest):
|
||||||
self.assertContains(response, '<input id="id_slug" maxlength="50" name="slug" type="text" value="first-post" />')
|
self.assertContains(response, '<input id="id_slug" maxlength="50" name="slug" type="text" value="first-post" />')
|
||||||
self.assertContains(response, '<option value="%s" selected="selected">Blog / sample_app</option>' % self.app_config_1.pk)
|
self.assertContains(response, '<option value="%s" selected="selected">Blog / sample_app</option>' % self.app_config_1.pk)
|
||||||
|
|
||||||
|
# Test for publish view
|
||||||
|
post.publish = False
|
||||||
|
post.save()
|
||||||
|
response = post_admin.publish_post(request, str(post.pk))
|
||||||
|
# Redirects to current post
|
||||||
|
self.assertEqual(response.status_code, 302)
|
||||||
|
self.assertEqual(response['Location'], post.get_absolute_url())
|
||||||
|
post = self.reload_model(post)
|
||||||
|
# post is publshed
|
||||||
|
self.assertTrue(post.publish)
|
||||||
|
|
||||||
|
# Non-existing post is redirected to posts list
|
||||||
|
response = post_admin.publish_post(request, str('1000000'))
|
||||||
|
self.assertEqual(response.status_code, 302)
|
||||||
|
self.assertEqual(response['Location'], reverse('djangocms_blog:posts-latest'))
|
||||||
|
|
||||||
|
# unless a referer is set
|
||||||
|
request.META['HTTP_REFERER'] = '/'
|
||||||
|
response = post_admin.publish_post(request, str('1000000'))
|
||||||
|
self.assertEqual(response.status_code, 302)
|
||||||
|
self.assertEqual(response['Location'], '/')
|
||||||
|
|
||||||
def test_admin_blogconfig_views(self):
|
def test_admin_blogconfig_views(self):
|
||||||
post_admin = admin.site._registry[BlogConfig]
|
post_admin = admin.site._registry[BlogConfig]
|
||||||
request = self.get_page_request('/', self.user, r'/en/blog/', edit=False)
|
request = self.get_page_request('/', self.user, r'/en/blog/', edit=False)
|
||||||
|
|
Loading…
Reference in a new issue