source: trunk/tests/testWYSIWYM.py @ 50

Revision 50, 2.8 KB checked in by laszlo, 14 years ago (diff)

closes #89 spent 90m

  • Property svn:eol-style set to LF
Line 
1#
2# Test case for WYSIWYM content
3#
4
5import os, sys, re
6if __name__ == '__main__':
7    execfile(os.path.join(sys.path[0], 'framework.py'))
8
9from Testing import ZopeTestCase
10from ToolboxTestCase import ToolboxTestCase
11from Products.CMFCore.utils import getToolByName
12from Products.PloneTestCase.setup import portal_owner, default_password
13
14types = ('Module',)
15auth=':'.join((portal_owner, default_password))
16
17class TestWYSIWYM(ToolboxTestCase):
18
19    def afterSetUp(self):
20        self.ID='TestModule'
21        self.ob=self.construct('Module',self.ID,self.folder)
22        self.addUser('foobar','foobar')
23
24    def testEditing(self):
25        path='/'.join((self.folder.absolute_url_path(),self.ID, 'base_edit'))
26        result=self.publish(path,basic=auth).getBody()
27        #raise "FOO",str(result)
28        self.failUnless(re.search('WYSIWYM Editor',result),"The comment 'WYSIWYM' is not found")
29       
30    def testHTMLRendering(self):
31        translations = (('*bold*','<p><b>bold</b></p>'),
32                        #('1 < 2 or 3 > 4/5', '<p>1 &lt; 2 or 3 &gt; 4/5</p>')
33                        ('Bolding*or*italics only_work_on whole words','<p>Bolding*or*italics only_work_on whole words</p>'),
34                        ('No * bold * here','<p>No * bold * here</p>'),
35                        ('*Several words* can _be affected_','<p><b>Several words</b> can <i>be affected</i></p>'),
36                        ('_italic_','<p><i>italic</i></p>'),
37                        ('Line1\r\n\r\nLine2','<p>Line1</p><p>Line2</p>'),
38                        ('Line1\r\nLine2','<p>Line1<br/>Line2</p>'),
39                        ('Line with *bold* in it\r\n\r\nLine with _italic_ in it.',
40                         '<p>Line with <b>bold</b> in it</p><p>Line with <i>italic</i> in it.</p>'),
41                        ('* Item1\r\n* Item2\r\n* Third item',
42                         '<ul><li>Item1</li><li>Item2</li><li>Third item</li></ul>'),
43                        ('# Item1\r\n# Item2\r\n# Third item',
44                         '<ol><li>Item1</li><li>Item2</li><li>Third item</li></ol>'),
45                        ('This is a [http://foo.bar Link].','<p>This is a <a href="http://foo.bar">Link</a>.</p>'),
46                        ('Paragraph1\r\n\r\n* Item1\r\n* Item2\r\n\r\nParagraph2',
47                         '<p>Paragraph1</p><ul><li>Item1</li><li>Item2</li></ul><p>Paragraph2</p>'),
48                        )
49        errors=''
50        for (body,rbody) in translations:
51            self.ob.edit(body=body)
52            if self.ob.getBody()!=rbody:
53                errors = errors + 'Wrong rendering for "%s": "%s" (expected "%s")\n' % (body,self.ob.getBody(),rbody)
54        self.failIf(errors,errors)
55
56def test_suite():
57    from unittest import TestSuite, makeSuite
58    suite = TestSuite()
59    suite.addTest(makeSuite(TestWYSIWYM))
60    return suite
61
62if __name__ == '__main__':
63    framework()
Note: See TracBrowser for help on using the repository browser.