Permalink
Browse files

Add test for toolbar_pool.toolbars sort order

  • Loading branch information...
1 parent 7f06aea commit d21515d9246e345664bb43be31554e5703af6c72 @yakky yakky committed Feb 27, 2014
Showing with 13 additions and 2 deletions.
  1. +13 −2 cms/tests/toolbar_pool.py
View
@@ -1,5 +1,6 @@
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
+from django.utils.datastructures import SortedDict
from cms.exceptions import ToolbarAlreadyRegistered, ToolbarNotRegistered
from cms.toolbar_base import CMSToolbar
@@ -23,16 +24,26 @@ def test_register(self):
'cms.tests.toolbar_pool.TestToolbar': TestToolbar})
self.assertRaises(ToolbarAlreadyRegistered,
- self.pool.register, TestToolbar)
+ self.pool.register, TestToolbar)
def test_register_type(self):
self.assertRaises(ImproperlyConfigured, self.pool.register, str)
self.assertRaises(ImproperlyConfigured, self.pool.register, object)
+ def test_register_order(self):
+ print(self.pool.toolbars)
+ self.pool.register(TestToolbar)
+ self.pool.register(CMSToolbar)
+
+ test_toolbar = SortedDict()
+ test_toolbar['cms.tests.toolbar_pool.TestToolbar'] = TestToolbar
+ test_toolbar['cms.toolbar_base.CMSToolbar'] = CMSToolbar
+ self.assertEqual(list(test_toolbar.keys()), list(self.pool.toolbars.keys()))
+
def test_unregister(self):
self.pool.register(TestToolbar)
self.pool.unregister(TestToolbar)
self.assertEqual(self.pool.toolbars, {})
self.assertRaises(ToolbarNotRegistered,
- self.pool.unregister, TestToolbar)
+ self.pool.unregister, TestToolbar)

0 comments on commit d21515d

Please sign in to comment.