Пример #1
0
    def test_unregister(self):
        pool = ToolbarPool()
        pool.register(TestToolbar)
        pool.unregister(TestToolbar)
        self.assertEqual(pool.toolbars, {})

        self.assertRaises(ToolbarNotRegistered, pool.unregister, TestToolbar)
Пример #2
0
    def test_unregister(self):
        pool = ToolbarPool()
        pool.register(TestToolbar)
        pool.unregister(TestToolbar)
        self.assertEqual(pool.toolbars, {})

        self.assertRaises(ToolbarNotRegistered,
                          pool.unregister, TestToolbar)
Пример #3
0
    def test_register_order(self):
        pool = ToolbarPool()
        pool.register(TestToolbar)
        pool.register(CMSToolbar)

        test_toolbar = OrderedDict()
        test_toolbar['cms.tests.test_toolbar_pool.TestToolbar'] = TestToolbar
        test_toolbar['cms.toolbar_base.CMSToolbar'] = CMSToolbar
        self.assertEqual(list(test_toolbar.keys()), list(pool.toolbars.keys()))
Пример #4
0
    def test_register_order(self):
        pool = ToolbarPool()
        pool.register(TestToolbar)
        pool.register(CMSToolbar)

        test_toolbar = OrderedDict()
        test_toolbar['cms.tests.test_toolbar_pool.TestToolbar'] = TestToolbar
        test_toolbar['cms.toolbar_base.CMSToolbar'] = CMSToolbar
        self.assertEqual(list(test_toolbar.keys()), list(pool.toolbars.keys()))
Пример #5
0
class ToolbarPoolTests(CMSTestCase):
    def setUp(self):
        self.pool = ToolbarPool()

    def test_register(self):
        self.pool.register(TestToolbar)
        self.pool.register(CMSToolbar)
        self.assertEqual(
            self.pool.toolbars, {
                'cms.toolbar_base.CMSToolbar': CMSToolbar,
                'cms.tests.toolbar_pool.TestToolbar': TestToolbar
            })

        self.assertRaises(ToolbarAlreadyRegistered, 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):
        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)

    def test_settings(self):
        toolbars = toolbar_pool.toolbars
        toolbar_pool.clear()
        with self.settings(CMS_TOOLBARS=[
                'cms.cms_toolbar.BasicToolbar',
                'cms.cms_toolbar.PlaceholderToolbar'
        ]):
            toolbar_pool.register(TestToolbar)
            self.assertEqual(len(list(self.pool.get_toolbars().keys())), 2)
            api.create_page("home", "simple.html", "en", published=True)
            with self.login_user_context(self.get_superuser()):
                response = self.client.get(
                    "/en/?%s" % get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON'))
                self.assertEqual(response.status_code, 200)
        toolbar_pool.toolbars = toolbars

    def test_watch_models(self):
        toolbar_pool.discover_toolbars()
        self.assertEqual(type(toolbar_pool.get_watch_models()), list)
Пример #6
0
    def test_register(self):
        pool = ToolbarPool()
        pool.register(TestToolbar)
        pool.register(CMSToolbar)
        self.assertEqual(pool.toolbars, {
            'cms.toolbar_base.CMSToolbar': CMSToolbar,
            'cms.tests.test_toolbar_pool.TestToolbar': TestToolbar})

        self.assertRaises(ToolbarAlreadyRegistered,
                          pool.register, TestToolbar)
Пример #7
0
    def test_register(self):
        pool = ToolbarPool()
        pool.register(TestToolbar)
        pool.register(CMSToolbar)
        self.assertEqual(
            pool.toolbars, {
                'cms.toolbar_base.CMSToolbar': CMSToolbar,
                'cms.tests.test_toolbar_pool.TestToolbar': TestToolbar
            })

        self.assertRaises(ToolbarAlreadyRegistered, pool.register, TestToolbar)
Пример #8
0
class ToolbarPoolTests(CMSTestCase):
    def setUp(self):
        self.pool = ToolbarPool()

    def test_register(self):
        self.pool.register(TestToolbar)
        self.pool.register(CMSToolbar)
        self.assertEqual(
            self.pool.toolbars,
            {"cms.toolbar_base.CMSToolbar": CMSToolbar, "cms.tests.toolbar_pool.TestToolbar": TestToolbar},
        )

        self.assertRaises(ToolbarAlreadyRegistered, 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):
        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)

    def test_settings(self):
        toolbars = toolbar_pool.toolbars
        toolbar_pool.clear()
        with self.settings(CMS_TOOLBARS=["cms.cms_toolbar.BasicToolbar", "cms.cms_toolbar.PlaceholderToolbar"]):
            toolbar_pool.register(TestToolbar)
            self.assertEqual(len(list(self.pool.get_toolbars().keys())), 2)
            api.create_page("home", "simple.html", "en", published=True)
            with self.login_user_context(self.get_superuser()):
                response = self.client.get("/en/?%s" % get_cms_setting("CMS_TOOLBAR_URL__EDIT_ON"))
                self.assertEqual(response.status_code, 200)
        toolbar_pool.toolbars = toolbars

    def test_watch_models(self):
        toolbar_pool.discover_toolbars()
        self.assertEqual(type(toolbar_pool.get_watch_models()), list)
Пример #9
0
class ToolbarPoolTests(CMSTestCase):

    def setUp(self):
        self.pool = ToolbarPool()

    def test_register(self):
        self.pool.register(TestToolbar)
        self.pool.register(CMSToolbar)
        self.assertEqual(self.pool.toolbars, {
            'cms.toolbar_base.CMSToolbar': CMSToolbar,
            'cms.tests.toolbar_pool.TestToolbar': TestToolbar})

        self.assertRaises(ToolbarAlreadyRegistered,
                          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):
        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)

    def test_settings(self):
        toolbars = toolbar_pool.toolbars
        toolbar_pool.clear()
        with SettingsOverride(CMS_TOOLBARS=['cms.cms_toolbar.BasicToolbar', 'cms.cms_toolbar.PlaceholderToolbar']):
            toolbar_pool.register(TestToolbar)
            self.assertEqual(len(list(self.pool.get_toolbars().keys())), 2)
            api.create_page("home", "simple.html", "en", published=True)
            with self.login_user_context(self.get_superuser()):
                response = self.client.get("/en/?edit")
                self.assertEqual(response.status_code, 200)
        toolbar_pool.toolbars = toolbars