Changeset 1042 in products


Ignore:
Timestamp:
Apr 22, 2009 2:05:54 PM (17 years ago)
Author:
koval
Message:

added tests for portlet renderer

Location:
quintagroup.portlet.cumulus/trunk/quintagroup/portlet/cumulus
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.portlet.cumulus/trunk/quintagroup/portlet/cumulus/cumulusportlet.pt

    r1038 r1042  
    1717                </p> 
    1818                <p style="padding: 1em; margin-bottom: 0;"> 
    19                     WP Cumulus Flash tag cloud by <a href="http://www.roytanck.com">Roy Tanck</a>  
     19                    WP Cumulus Flash tag cloud by <a href="http://www.roytanck.com">Roy Tanck</a> 
    2020                    requires Flash Player 9 or better. 
    2121                </p> 
     
    4141                <p style="padding: 1em;" tal:content="structure view/getTagAnchors"></p> 
    4242                <p style="padding: 1em; margin-bottom: 0;"> 
    43                     WP-Cumulus by <a href="http://www.roytanck.com/">Roy Tanck</a>  
     43                    WP-Cumulus by <a href="http://www.roytanck.com/">Roy Tanck</a> 
    4444                    requires Flash Player 9 or better. 
    4545                </p> 
  • quintagroup.portlet.cumulus/trunk/quintagroup/portlet/cumulus/tests/base.py

    r1003 r1042  
    66from Products.PloneTestCase import PloneTestCase as ptc 
    77from Products.PloneTestCase.layer import onsetup 
     8 
     9try: 
     10    import Products.QuillsEnabled 
     11    HAS_QUILLS_ENABLED = True 
     12except ImportError: 
     13    HAS_QUILLS_ENABLED = False 
    814 
    915@onsetup 
     
    2733 
    2834    ztc.installPackage('quintagroup.portlet.cumulus') 
     35    if HAS_QUILLS_ENABLED: 
     36        ztc.installProduct('QuillsEnabled') 
    2937 
    3038# The order here is important: We first call the deferred function and then 
     
    3240 
    3341setup_product() 
    34 ptc.setupPloneSite(products=['quintagroup.portlet.cumulus']) 
     42prods = ['quintagroup.portlet.cumulus'] 
     43if HAS_QUILLS_ENABLED: 
     44    prods.append('QuillsEnabled') 
     45ptc.setupPloneSite(products=prods) 
    3546 
    3647class TestCase(ptc.PloneTestCase): 
  • quintagroup.portlet.cumulus/trunk/quintagroup/portlet/cumulus/tests/test_portlet.py

    r1003 r1042  
     1from zope.interface import alsoProvides 
    12from zope.component import getUtility, getMultiAdapter 
    23 
     
    1112from quintagroup.portlet.cumulus import cumulusportlet 
    1213 
    13 from quintagroup.portlet.cumulus.tests.base import TestCase 
    14  
     14from quintagroup.portlet.cumulus.tests.base import TestCase, HAS_QUILLS_ENABLED 
    1515 
    1616class TestPortlet(TestCase): 
     
    2727 
    2828    def test_interfaces(self): 
    29         # TODO: Pass any keyword arguments to the Assignment constructor 
    3029        portlet = cumulusportlet.Assignment() 
    3130        self.failUnless(IPortletAssignment.providedBy(portlet)) 
     
    4140            del mapping[m] 
    4241        addview = mapping.restrictedTraverse('+/' + portlet.addview) 
    43  
    44         # TODO: Pass a dictionary containing dummy form inputs from the add 
    45         # form. 
    46         # Note: if the portlet has a NullAddForm, simply call 
    47         # addview() instead of the next line. 
    4842        addview.createAndAdd(data={}) 
    4943 
     
    5347 
    5448    def test_invoke_edit_view(self): 
    55         # NOTE: This test can be removed if the portlet has no edit form 
    5649        mapping = PortletAssignmentMapping() 
    5750        request = self.folder.REQUEST 
     
    6861                             context=self.portal) 
    6962 
    70         # TODO: Pass any keyword arguments to the Assignment constructor 
    7163        assignment = cumulusportlet.Assignment() 
    7264 
     
    8072    def afterSetUp(self): 
    8173        self.setRoles(('Manager', )) 
     74        self.portal['front-page'].edit(subject=['global', 'tags']) 
     75        id_ = self.folder.invokeFactory('Document', id='blog-entry') 
     76        self.folder[id_].edit(subject=['blog', 'tags']) 
     77        if HAS_QUILLS_ENABLED: 
     78            from quills.core.interfaces import IWeblogEnhanced 
     79            alsoProvides(self.folder, IWeblogEnhanced) 
     80            self.folder.reindexObject() 
    8281 
    8382    def renderer(self, context=None, request=None, view=None, manager=None, 
     
    8988            IPortletManager, name='plone.rightcolumn', context=self.portal) 
    9089 
    91         # TODO: Pass any default keyword arguments to the Assignment 
    92         # constructor. 
    9390        assignment = assignment or cumulusportlet.Assignment() 
    9491        return getMultiAdapter((context, request, view, manager, assignment), 
    9592                               IPortletRenderer) 
    9693 
    97     def test_render(self): 
    98         # TODO: Pass any keyword arguments to the Assignment constructor. 
     94    def test_render_default(self): 
    9995        r = self.renderer(context=self.portal, 
    10096                          assignment=cumulusportlet.Assignment()) 
     
    10298        r.update() 
    10399        output = r.render() 
    104         # TODO: Test output 
     100        expected = """<script type="text/javascript" 
     101                    src="http://nohost/plone/++resource++swfobject.js"> 
     102            </script> 
     103            <div id="comulus"> 
     104                <p style="display:none;"><a href="http://nohost/plone/search?Subject:list=blog" title="1 entries" rel="tag" style="font-size: 8.0pt;">blog</a> 
     105<a href="http://nohost/plone/search?Subject:list=global" title="1 entries" rel="tag" style="font-size: 8.0pt;">global</a> 
     106<a href="http://nohost/plone/search?Subject:list=tags" title="2 entries" rel="tag" style="font-size: 22.0pt;">tags</a> 
     107</p> 
     108                <p style="padding: 1em; margin-bottom: 0;"> 
     109                    WP Cumulus Flash tag cloud by <a href="http://www.roytanck.com">Roy Tanck</a> 
     110                    requires Flash Player 9 or better. 
     111                </p> 
     112            </div> 
     113            <script type="text/javascript"> 
     114                var so = new SWFObject("http://nohost/plone/++resource++tagcloud.swf", "tagcloudflash", "152", "152", "9", "#ffffff"); 
     115                 
     116                so.addParam("allowScriptAccess", "always"); 
     117                so.addVariable("tcolor", "0x5391d0"); 
     118                so.addVariable("tcolor2", "0x333333"); 
     119                so.addVariable("hicolor", "0x578308"); 
     120                so.addVariable("tspeed", "100"); 
     121                so.addVariable("distr", "true"); 
     122                so.addVariable("mode", "tags"); 
     123                so.addVariable("tagcloud", "%3Ctags%3E%3Ca%20href%3D%22http%3A//nohost/plone/search%3FSubject%3Alist%3Dblog%22%20title%3D%221%20entries%22%20rel%3D%22tag%22%20style%3D%22font-size%3A%208.0pt%3B%22%3Eblog%3C/a%3E%0A%3Ca%20href%3D%22http%3A//nohost/plone/search%3FSubject%3Alist%3Dglobal%22%20title%3D%221%20entries%22%20rel%3D%22tag%22%20style%3D%22font-size%3A%208.0pt%3B%22%3Eglobal%3C/a%3E%0A%3Ca%20href%3D%22http%3A//nohost/plone/search%3FSubject%3Alist%3Dtags%22%20title%3D%222%20entries%22%20rel%3D%22tag%22%20style%3D%22font-size%3A%2022.0pt%3B%22%3Etags%3C/a%3E%0A%3C/tags%3E"); 
     124                so.write("comulus"); 
     125            </script>""" 
     126        self.failUnless(expected in output, 'Bad output') 
    105127 
     128    def test_render_compmode(self): 
     129        r = self.renderer(context=self.portal, 
     130                          assignment=cumulusportlet.Assignment(compmode=True, width=200, height=200)) 
     131        r = r.__of__(self.folder) 
     132        r.update() 
     133        output = r.render() 
     134        expected = """<object type="application/x-shockwave-flash" 
     135                    data="http://nohost/plone/++resource++tagcloud.swf" 
     136                    width="200" height="200"> 
     137                <param name="movie" 
     138                       value="http://nohost/plone/++resource++tagcloud.swf" /> 
     139                <param name="bgcolor" value="ffffff" /> 
     140                <param name="AllowScriptAccess" value="always"> 
     141                 
     142                <param name="flashvars" 
     143                       value="tcolor=5391d0&amp;tcolor2=333333&amp;hicolor=578308&amp;tspeed=100&amp;distr=true&amp;mode=tags&amp;tagcloud=%3Ctags%3E%3Ca%20href%3D%22http%3A//nohost/plone/search%3FSubject%3Alist%3Dblog%22%20title%3D%221%20entries%22%20rel%3D%22tag%22%20style%3D%22font-size%3A%208.0pt%3B%22%3Eblog%3C/a%3E%0A%3Ca%20href%3D%22http%3A//nohost/plone/search%3FSubject%3Alist%3Dglobal%22%20title%3D%221%20entries%22%20rel%3D%22tag%22%20style%3D%22font-size%3A%208.0pt%3B%22%3Eglobal%3C/a%3E%0A%3Ca%20href%3D%22http%3A//nohost/plone/search%3FSubject%3Alist%3Dtags%22%20title%3D%222%20entries%22%20rel%3D%22tag%22%20style%3D%22font-size%3A%2022.0pt%3B%22%3Etags%3C/a%3E%0A%3C/tags%3E" /> 
     144                <p style="padding: 1em;"><a href="http://nohost/plone/search?Subject:list=blog" title="1 entries" rel="tag" style="font-size: 8.0pt;">blog</a> 
     145<a href="http://nohost/plone/search?Subject:list=global" title="1 entries" rel="tag" style="font-size: 8.0pt;">global</a> 
     146<a href="http://nohost/plone/search?Subject:list=tags" title="2 entries" rel="tag" style="font-size: 22.0pt;">tags</a> 
     147</p> 
     148                <p style="padding: 1em; margin-bottom: 0;"> 
     149                    WP-Cumulus by <a href="http://www.roytanck.com/">Roy Tanck</a> 
     150                    requires Flash Player 9 or better. 
     151                </p> 
     152            </object>""" 
     153        self.failUnless(expected in output, 'Bad output') 
     154 
     155    if HAS_QUILLS_ENABLED: 
     156        def test_render_on_blog(self): 
     157            r = self.renderer(context=self.folder, 
     158                            assignment=cumulusportlet.Assignment(compmode=True, width=200, height=200)) 
     159            r = r.__of__(self.folder) 
     160            r.update() 
     161            output = r.render() 
     162            expected = """<param name="flashvars" 
     163                       value="tcolor=5391d0&amp;tcolor2=333333&amp;hicolor=578308&amp;tspeed=100&amp;distr=true&amp;mode=tags&amp;tagcloud=%3Ctags%3E%3Ca%20href%3D%22http%3A//nohost/plone/Members/test_user_1_/topics/blog%22%20title%3D%220%20entries%22%20rel%3D%22tag%22%20style%3D%22font-size%3A%208.0pt%3B%22%3Eblog%3C/a%3E%0A%3Ca%20href%3D%22http%3A//nohost/plone/Members/test_user_1_/topics/tags%22%20title%3D%220%20entries%22%20rel%3D%22tag%22%20style%3D%22font-size%3A%208.0pt%3B%22%3Etags%3C/a%3E%0A%3C/tags%3E" />""" 
     164            self.failUnless(expected in output, 'Bad output') 
    106165 
    107166def test_suite(): 
Note: See TracChangeset for help on using the changeset viewer.