Ejemplo n.º 1
0
 def update(self):
     Core.update(self)
     self.request['plone.leftcolumn'] = False
     self.request['plone.rightcolumn'] = False
     self.context_url = self.context.absolute_url()
     if self.content_template_name:
         template_name = '../templates/%s' % self.content_template_name
         self.contents = ViewPageTemplateFile(template_name)(self)
Ejemplo n.º 2
0
class UnitTestCoreView(base.UnitTestCase):
    """We tests the setup (install) of the addons. You should check all
    stuff in profile are well activated (browserlayer, js, content types, ...)
    """

    def setUp(self):
        super(UnitTestCoreView, self).setUp()
        self.context = utils.FakeContext()
        self.request = Request()
        self.view = Core(self.context, self.request)

    def test_cached_tools(self):
        self.view.cached_tools['portal_catalog'] = 'catalog'
        self.assertEqual(self.view.get_tool('portal_catalog'), 'catalog')

    def test_cached_components(self):
        self.view.cached_components['views'] = 'my component'
        self.assertEqual(self.view.get_views(), 'my component')

        key = 'views.collective.wpadmin.pages.page.IPage'
        self.view.cached_components[key] = 'my views'
        self.assertEqual(self.view.get_views(interface=IPage), 'my views')

        self.view.cached_components['vocabulary_me'] = 'vocab'
        self.assertEqual(self.view.get_vocabulary(name='me'), 'vocab')

        self.view.cached_components['plone_portal_state'] = 'pstate'
        self.assertEqual(self.view.get_portal_state(), 'pstate')

        status = utils.FakeStatusMessage(self.request)
        status.add("message")
        self.view.cached_components['statusmessage'] = status
        self.assertEqual(self.view.get_messages(), ['<p>message</p>'])

    def test_query_catalog(self):
        query = self.view.get_query()
        self.view.cached_tools['portal_catalog'] = utils.FakeCatalog()
        res = self.view.query_catalog(query)
        self.assertEqual(len(res), 2)
Ejemplo n.º 3
0
 def setUp(self):
     super(UnitTestCoreView, self).setUp()
     self.context = utils.FakeContext()
     self.request = Request()
     self.view = Core(self.context, self.request)
Ejemplo n.º 4
0
 def __init__(self, context, request):
     Core.__init__(self, context, request)
Ejemplo n.º 5
0
 def __init__(self, page):
     Core.__init__(self, page.context, page.request)
     self.page = page