示例#1
0
    def testInvokeEditView(self):
        mapping = PortletAssignmentMapping()
        request = self.folder.REQUEST

        mapping['foo'] = richportlet.Assignment(title=u"rich portlet title", text="rich portlet text")
        editview = getMultiAdapter((mapping['foo'], request), name='edit')
        self.failUnless(isinstance(editview, richportlet.EditForm))
示例#2
0
 def test_render_has_title_link(self):
     r = self.renderer(context=self.portal, assignment=richportlet.Assignment(title=u"rich portlet title", title_more_url="http://www.plone.org", text="<b>rich portlet text</b>"))
     r = r.__of__(self.folder)
     r.update()
     output = r.render()
     # print output
     self.failUnless('<a href="http://www.plone.org">rich portlet title</a>' in output)
     self.failUnless('<b>rich portlet text</b>' in output)
示例#3
0
 def test_render(self):
     r = self.renderer(context=self.portal, assignment=richportlet.Assignment(title=u"rich portlet title", text="<b>rich portlet text</b>"))
     r = r.__of__(self.folder)
     r.update()
     output = r.render()
     # print output
     self.failUnless('rich portlet title' in output)
     self.failUnless('<b>rich portlet text</b>' in output)
示例#4
0
    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 richportlet.Assignment(title=u"rich portlet title", text="rich portlet text")

        return getMultiAdapter((context, request, view, manager, assignment), IPortletRenderer)
示例#5
0
    def testRenderer(self):
        context = self.folder
        request = self.folder.REQUEST
        view = self.folder.restrictedTraverse('@@plone')
        manager = getUtility(IPortletManager, name='plone.rightcolumn', context=self.portal)
        assignment = richportlet.Assignment(title=u"rich portlet title", text="rich portlet text")

        renderer = getMultiAdapter((context, request, view, manager, assignment), IPortletRenderer)
        self.failUnless(isinstance(renderer, richportlet.Renderer))
示例#6
0
 def test_render_has_text_only_html_tags(self):
     
     html_tags_no_text = "  \n\n         <p><br %><b></b></p>    \n  \n    <br />          "
     r = self.renderer(context=self.portal, assignment=richportlet.Assignment(title=u"rich portlet title", title_more_url="http://www.plone.org", text=html_tags_no_text))
     r = r.__of__(self.folder)
     r.update()
     output = r.render()
     # print output
     self.failIf(html_tags_no_text in output)
示例#7
0
 def test_render_get_title_image_tag_scale(self):
     self.folder.invokeFactory('Image', id='image')
     target_title_image = '/Members/test_user_1_/image'
     r = self.renderer(context=self.portal, assignment=richportlet.Assignment(target_title_image=target_title_image, title=u"rich portlet title", text="<b>rich portlet text</b>", scale='thumb'))
     r = r.__of__(self.folder)
     r.update()
     output = r.render()
     # print output
     image_tag = '<img src="http://nohost/plone/Members/test_user_1_/image/image_thumb" alt="" title="" height="0" width="0" />'
     self.failUnless(image_tag in output)
示例#8
0
    def test_render_list_links(self):
        links = (
            ExternalLink(u'http://www.plone.org', u'Link title 1', u'Link description 1'),
            ExternalLink(u'http://www.python.org', u'Link title 2', u'Link description 2'))

        r = self.renderer(context=self.portal, assignment=richportlet.Assignment(title=u"rich portlet title", text="<b>rich portlet text</b>", links = links,))
        r = r.__of__(self.folder)
        r.update()
        output = r.render()
        # print output
        self.failUnless('href="http://www.plone.org"' in output)
        self.failUnless('title="Link description 1">Link title 1' in output)
示例#9
0
    def test_render_list_links_internal(self):
        links = (
            InternalLink(self.portal['front-page'].UID(),
                         u'Internal link title 1',
                         u'Internal link description 1'),
            InternalLink(self.portal['news'].UID(),
                         u'Internal link title 2',
                         u'Internal link description 2'))

        r = self.renderer(context=self.portal, assignment=richportlet.Assignment(title=u"rich portlet title", text="<b>rich portlet text</b>", links = links,))
        r = r.__of__(self.folder)
        r.update()
        output = r.render()
        # print output
        self.failUnless('href="http://nohost/plone/front-page' in output)
        self.failUnless('title="Internal link description 1">Internal link title 1' in output)
示例#10
0
 def testInterfaces(self):
     portlet = richportlet.Assignment(title=u"title", text="text")
     self.failUnless(IPortletAssignment.providedBy(portlet))
     self.failUnless(IPortletDataProvider.providedBy(portlet.data))
示例#11
0
 def test_css_class(self):
     r = self.renderer(context=self.portal, 
                       assignment=richportlet.Assignment(title=u"Rich portlet title", text="<b>rich portlet text</b>"))
     self.assertEquals('portlet-richportlet-rich-portlet-title', r.css_class())