djangocms_blog/tests/test_toolbar.py

29 lines
1.2 KiB
Python
Raw Normal View History

2014-06-09 22:11:48 +00:00
# -*- coding: utf-8 -*-
2015-09-12 22:46:05 +00:00
from __future__ import absolute_import, print_function, unicode_literals
2014-06-09 22:11:48 +00:00
from cms.toolbar.items import ModalItem
from django.core.urlresolvers import reverse
2015-09-12 22:33:13 +00:00
2014-06-09 22:11:48 +00:00
from djangocms_blog.models import BLOG_CURRENT_POST_IDENTIFIER
2015-10-18 11:16:43 +00:00
from .base import BaseTest
2014-06-09 22:11:48 +00:00
class ToolbarTest(BaseTest):
def test_toolbar_with_items(self):
"""
Test that Blog toolbar is present and contains all items
"""
from cms.toolbar.toolbar import CMSToolbar
2015-09-19 23:11:14 +00:00
posts = self.get_posts()
pages = self.get_pages()
request = self.get_page_request(pages[0], self.user, r'/en/blog/', edit=True)
setattr(request, BLOG_CURRENT_POST_IDENTIFIER, posts[0])
2014-06-09 22:11:48 +00:00
toolbar = CMSToolbar(request)
toolbar.get_left_items()
blog_menu = toolbar.menus['djangocms_blog']
self.assertEqual(len(blog_menu.find_items(ModalItem, url=reverse('admin:djangocms_blog_post_changelist'))), 1)
self.assertEqual(len(blog_menu.find_items(ModalItem, url=reverse('admin:djangocms_blog_post_add'))), 1)
2015-09-19 23:11:14 +00:00
self.assertEqual(len(blog_menu.find_items(ModalItem, url=reverse('admin:djangocms_blog_post_change', args=(posts[0].pk,)))), 1)