def testObtainRenderer(self):
        context = self.folder
        request = self.folder.REQUEST
        view = self.folder.restrictedTraverse('@@plone')
        manager = getUtility(IPortletManager,
                             name='plone.rightcolumn',
                             context=self.portal)

        assignment = portlet_mod.Assignment()

        renderer = getMultiAdapter(
            (context, request, view, manager, assignment), IPortletRenderer)
        self.failUnless(isinstance(renderer, portlet_mod.Renderer))
    def renderer(self,
                 context=None,
                 request=None,
                 view=None,
                 manager=None,
                 assignment=None):
        context = context or self.folder
        request = request or self.folder.REQUEST
        view = view or self.folder.restrictedTraverse('@@plone')
        manager = manager or getUtility(
            IPortletManager, name='plone.rightcolumn', context=self.portal)

        assignment = assignment or portlet_mod.Assignment()
        return getMultiAdapter((context, request, view, manager, assignment),
                               IPortletRenderer)
 def testRender(self):
     r = self.renderer(context=self.portal,
                       assignment=portlet_mod.Assignment(title="Test Title",
                                                         items_shown=2,
                                                         feeds=FEED_ONE))
     r = r.__of__(self.folder)
     r.update()
     output = r.render()
     self.failUnless("Test Title" in output)
     self.failUnless("Feed One Item One" in output)
     self.failUnless("Nov 02, 2007" in output)
     self.failUnless("http://test.one/item/1" in output)
     self.failUnless("Feed One Item Two" in output)
     self.failUnless("Nov 01, 2007" in output)
     self.failUnless("http://test.one/item/2" in output)
     self.failUnless("http://test.one/item/3" not in output)
    def testInvokeEditView(self):
        mapping = PortletAssignmentMapping()
        request = self.folder.REQUEST

        mapping['foo'] = portlet_mod.Assignment()
        editview = getMultiAdapter((mapping['foo'], request), name='edit')
        self.failUnless(isinstance(editview, portlet_mod.EditForm))

        editview.setUpWidgets(True)
        editview.handle_edit_action.success(
            dict(title="Test Title",
                 feeds="Test Feeds",
                 items_shown=16,
                 cache_timeout="32"))
        assignment = mapping.values()[0]
        self.failUnless(isinstance(assignment, portlet_mod.Assignment))
        self.assertEqual(assignment.title, "Test Title")
        self.assertEqual(assignment.feeds, "Test Feeds")
        self.assertEqual(assignment.items_shown, 16)
        self.assertEqual(assignment.cache_timeout, "32")
 def testInterfaces(self):
     portlet = portlet_mod.Assignment()
     self.failUnless(IPortletAssignment.providedBy(portlet))
     self.failUnless(IPortletDataProvider.providedBy(portlet.data))