Changeset 1622


Ignore:
Timestamp:
04/04/07 13:46:49 (13 years ago)
Author:
szabolcs
Message:

tests for getBodyText

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Resources.py

    r1592 r1622  
    9393            return False 
    9494 
    95 #    def getBodyText(self): 
    96 #        """ get body text """ 
    97 #        lt = getToolByName(self, 'lemill_tool') 
    98 #        bodytextfield = self.getField('bodyText') 
    99 #        if not bodytextfield: 
    100 #            return None 
    101 # 
    102 #        bodytext = bodytextfield.get(self) 
    103 #        if type(bodytext) in StringTypes: 
    104 #            return lt.shorten_link_names(lt.htmlify(bodytext)) 
    105 #        else: 
    106 #            if bodytext and reduce(lambda x, y: x and y, (type(s) in StringTypes for s in bodytext), True): 
    107 #                return [lt.shorten_link_names(lt.htmlify(s)) for s in bodytext] 
    108 #            else: 
    109 #                return bodytext 
     95    def getBodyText(self): 
     96        """ get body text """ 
     97        lt = getToolByName(self, 'lemill_tool') 
     98        bodytextfield = self.getField('bodyText') 
     99        if not bodytextfield: 
     100            return None 
     101 
     102        bodytext = bodytextfield.get(self) 
     103        if type(bodytext) in StringTypes: 
     104            return lt.shorten_link_names(lt.htmlify(bodytext)) 
     105        else: 
     106            if bodytext and reduce(lambda x, y: x and y, (type(s) in StringTypes for s in bodytext), True): 
     107                return [lt.shorten_link_names(lt.htmlify(s)) for s in bodytext] 
     108            else: 
     109                return bodytext 
    110110 
    111111InitializeClass(CommonMixIn) 
  • trunk/tests/testActivity.py

    r1385 r1622  
    6161        self.login('foobar') 
    6262        ob=self.construct('Activity', 'TestActivity' ,self.portal.methods) 
    63         path= ob.absolute_url_path()         
     63        path= ob.absolute_url_path() 
    6464        result=self.publish(path,basic=auth).getBody() 
    6565        self.failUnless(re.search('Translate...',result), 
    6666            "Translate-link not visible.") 
     67 
     68    def testBodyText(self): 
     69        ob=self.construct('Activity', 'getbodytext test', self.portal.methods) 
     70        ob.edit(bodyText='huigrehr\ngyuiwgre\n\nhuigrwegr\nhttp://index.hu/huigrehgr/hrehuwigw/ehreuqihgrehr/ehjreugihrtre/htjreuihreuige/gre/gre/gr') 
     71        self.assertEqual(ob.getBodyText(), 'huigrehr<br />gyuiwgre</p><p>huigrwegr<br /><a href="http://index.hu/huigrehgr/hrehuwigw/ehreuqihgrehr/ehjreugihrtre/htjreuihreuige/gre/gre/gr">http://index.hu/.../gr</a>') 
    6772 
    6873     
  • trunk/tests/testGroups.py

    r1575 r1622  
    9797        self.failIf(re.search('already a member', result.getBody()), "marked as member in group invite form when shouldn't be"+result.getBody()) 
    9898        # 4) if our invitee is already a member, there should be a notion of that 
    99         self.login('invited')         
    100         self.workspace1.join_group()  
     99        self.login('invited') 
     100        self.workspace1.join_group() 
    101101        result=self.publish(self.portal.community.invited.absolute_url_path()+'/group_invite', basic=iauth) # this is still ran as portal_owner 
    102102        self.failUnless(re.search('already a member', result.getBody()), "member is already in group, but it doesn't get noticed"+result.getBody())               
     
    112112        ob = self.construct('BlogPost','TestPost',self.portal.community.testgroup) 
    113113        ob.processForm(values={'title':TITLE,'bodyText':VALUE}) 
    114         ob.at_post_edit_script()            
     114        ob.at_post_edit_script() 
    115115        result=self.publish(self.portal.absolute_url_path()+'/community/testgroup', basic=auth) 
    116         self.failUnless(re.search(TITLE, result.getBody()), "can't find post title from group's blog"+result.getBody()) 
     116        self.failUnless(result.getBody().find(TITLE) != -1, "can't find post title from group's blog"+result.getBody()) 
     117        self.failUnless(result.getBody().find(TITLE) != -1, "can't find post title from group's blog"+result.getBody()) 
    117118        result=self.publish(self.portal.absolute_url_path()+'/community/testgroup/thesethingstaketime', basic=auth) 
    118         self.failUnless(re.search(VALUE, result.getBody()), "can't find post body from post"+result.getBody()) 
    119         self.failUnless(re.search('textarea', result.getBody()) and re.search('name="body_text"', result.getBody()), "comment box not visible for post"+result.getBody()) 
    120          
     119        self.failUnless(result.getBody().find(VALUE) != -1, "can't find post body from post"+result.getBody()) 
     120        self.failUnless(result.getBody().find('textarea') != -1 and result.getBody().find('name="body_text"') != -1, "comment box not visible for post"+result.getBody()) 
     121 
     122        ob = self.construct('BlogPost','TestPost',self.portal.community.testgroup) 
     123        ob.processForm(values={'title':TITLE,'bodyText':'huigrehr\ngyuiwgre\n\nhuigrwegr\nhttp://index.hu/huigrehgr/hrehuwigw/ehreuqihgrehr/ehjreugihrtre/htjreuihreuige/gre/gre/gr'}) 
     124        self.assertEqual(ob.getBodyText(), 'huigrehr<br />gyuiwgre</p><p>huigrwegr<br /><a href="http://index.hu/huigrehgr/hrehuwigw/ehreuqihgrehr/ehjreugihrtre/htjreuihreuige/gre/gre/gr">http://index.hu/.../gr</a>') 
     125 
    121126    def testBlogPostsInCommunityFrontPage(self): 
    122127        self.addUser('foobar','foobar', ('Member',)) 
     
    132137            ob = self.construct('BlogPost',ID,self.portal.community.testgroup) 
    133138            ob.processForm(values={'title':TITLE,'bodyText':BODY}) 
    134             ob.at_post_edit_script()            
     139            ob.at_post_edit_script() 
    135140        result=self.publish(self.portal.absolute_url_path()+'/community', basic='foobar:foobar') 
    136141        TITLE=cases[0][1] 
  • trunk/tests/testMaterial.py

    r1382 r1622  
    161161        self.failUnless(len(ob.getAuthors())==2,"Number of authors incorrect") 
    162162 
    163                  
     163    def testBodyText(self): 
     164        ob=self.construct('MultimediaMaterial', 'getbodytext test', self.portal.content) 
     165        ob.edit(bodyText=['http://index.hu', 'huigrehr\ngyuiwgre\n\nhuigrwegr\nhttp://index.hu/huigrehgr/hrehuwigw/ehreuqihgrehr/ehjreugihrtre/htjreuihreuige/gre/gre/gr']) 
     166        self.assertEqual(ob.getBodyText(), ['<a href="http://index.hu">http://index.hu</a>', 'huigrehr<br />gyuiwgre</p><p>huigrwegr<br /><a href="http://index.hu/huigrehgr/hrehuwigw/ehreuqihgrehr/ehjreugihrtre/htjreuihreuige/gre/gre/gr">http://index.hu/.../gr</a>']) 
     167 
    164168def test_suite(): 
    165169    from unittest import TestSuite, makeSuite 
  • trunk/tests/testPilotMaterial.py

    r1038 r1622  
    7979        ob.edit(bodyText='This is the third body') 
    8080        self.failUnless(len(ob.getAuthors())==2,"Number of authors incorrect") 
     81 
     82    def testBodyText(self): 
     83        ob=self.construct('PILOTMaterial', 'getbodytext test', self.portal.content) 
     84        bt = ['http://index.hu', 'huigrehr\ngyuiwgre\n\nhuigrwegr\nhttp://index.hu/huigrehgr/hrehuwigw/ehreuqihgrehr/ehjreugihrtre/htjreuihreuige/gre/gre/gr', ['', '', '']] 
     85        ob.edit(bodyText=bt) 
     86        self.assertEqual(ob.getBodyText(), bt) 
    8187        
    8288class TestMaterialPieces(LeMillTestCase): 
  • trunk/tests/testPresentation.py

    r750 r1622  
    8686        self.failUnless(len(ob.getAuthors())==2,"Number of authors incorrect") 
    8787        
     88    def testBodyText(self): 
     89        ob=self.construct('PresentationMaterial', 'getbodytext test', self.portal.content) 
     90        ob.edit(bodyText=['http://index.hu', 'huigrehr\ngyuiwgre\n\nhuigrwegr\nhttp://index.hu/huigrehgr/hrehuwigw/ehreuqihgrehr/ehjreugihrtre/htjreuihreuige/gre/gre/gr']) 
     91        self.assertEqual(ob.getBodyText(), ['<a href="http://index.hu">http://index.hu</a>', 'huigrehr<br />gyuiwgre</p><p>huigrwegr<br /><a href="http://index.hu/huigrehgr/hrehuwigw/ehreuqihgrehr/ehjreugihrtre/htjreuihreuige/gre/gre/gr">http://index.hu/.../gr</a>']) 
     92 
    8893class TestMaterialPieces(LeMillTestCase): 
    8994 
  • trunk/tests/testTool.py

    r1543 r1622  
    6262        self.login('foobar') 
    6363        ob=self.construct('Tool', 'TestTool' ,self.portal.tools) 
    64         path= ob.absolute_url_path()         
     64        path= ob.absolute_url_path() 
    6565        result=self.publish(path,basic=auth).getBody() 
    6666        self.failUnless(re.search('Translate...',result), 
    6767            "Translate-link not visible.") 
     68 
     69    def testBodyText(self): 
     70        ob=self.construct('Tool', 'getbodytext test', self.portal.tools) 
     71        ob.edit(bodyText='huigrehr\ngyuiwgre\n\nhuigrwegr\nhttp://index.hu/huigrehgr/hrehuwigw/ehreuqihgrehr/ehjreugihrtre/htjreuihreuige/gre/gre/gr') 
     72        self.assertEqual(ob.getBodyText(), 'huigrehr<br />gyuiwgre</p><p>huigrwegr<br /><a href="http://index.hu/huigrehgr/hrehuwigw/ehreuqihgrehr/ehjreugihrtre/htjreuihreuige/gre/gre/gr">http://index.hu/.../gr</a>') 
    6873 
    6974 
Note: See TracChangeset for help on using the changeset viewer.