[Zope3-checkins] CVS: Products3/demo/messageboard/step13/browser/tests - __init__.py:1.1 test_widgets.py:1.1

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Aug 22 22:18:48 EDT 2003


Update of /cvs-repository/Products3/demo/messageboard/step13/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv13031/step13/browser/tests

Added Files:
	__init__.py test_widgets.py 
Log Message:
Step 13 of the message board. This time I hooked up the new Smiley Service,
so that message bodies display smiley images instead of their text 
representation.


=== Added File Products3/demo/messageboard/step13/browser/tests/__init__.py ===
# Package Maker


=== Added File Products3/demo/messageboard/step13/browser/tests/test_widgets.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""HTMLSourceWidget Tests

$Id: test_widgets.py,v 1.1 2003/08/23 01:18:47 srichter Exp $
"""
import unittest
from zope.app.browser.form.tests.test_textareawidget import \
     TextAreaWidgetTest
from zopeproducts.messageboard.browser.widgets import HTMLSourceWidget
from zopeproducts.messageboard.fields import HTML

class HTMLSourceWidgetTest(TextAreaWidgetTest):

    _FieldFactory = HTML
    _WidgetFactory = HTMLSourceWidget


    def test_AllowedTagsConvert(self):
        widget = self._widget
        widget.context.allowed_tags=('h1','pre')
        self.assertEqual(u'<h1>Blah</h1>',
                         widget._convert(u'<h1>Blah</h1>')) 
        self.assertEqual(u'<pre>Blah</pre>',
                         widget._convert(u'<pre>Blah</pre>') )
        self.assertEqual(u'<h1><pre>Blah</pre></h1>',
                         widget._convert(u'<h1><pre>Blah</pre></h1>')) 
        self.assertEqual(u'<h1 attr=".">Blah</h1>',
                         widget._convert(u'<h1 attr=".">Blah</h1>')) 

        self.assertEqual(u'Blah',
                         widget._convert(u'<h2>Blah</h2>')) 
        self.assertEqual(u'<pre>Blah</pre>',
                         widget._convert(u'<h2><pre>Blah</pre></h2>')) 
        self.assertEqual(u'Blah',
                         widget._convert(u'<h2 a="b">Blah</h2>')) 


    def test_ForbiddenTagsConvert(self):
        widget = self._widget
        widget.context.forbidden_tags=('h2','pre')

        self.assertEqual(u'<h1>Blah</h1>',
                         widget._convert(u'<h1>Blah</h1>')) 
        self.assertEqual(u'<h1 a="b">Blah</h1>',
                         widget._convert(u'<h1 a="b">Blah</h1>')) 

        self.assertEqual(u'Blah',
                         widget._convert(u'<h2>Blah</h2>')) 
        self.assertEqual(u'Blah',
                         widget._convert(u'<pre>Blah</pre>')) 
        self.assertEqual(u'Blah',
                         widget._convert(u'<h2><pre>Blah</pre></h2>')) 
        self.assertEqual(u'Blah',
                         widget._convert(u'<h2><pre>Blah</pre></h2>')) 
        self.assertEqual(u'<h1>Blah</h1>',
                         widget._convert(u'<h1><pre>Blah</pre></h1>')) 


def test_suite():
    return unittest.TestSuite((
        unittest.makeSuite(HTMLSourceWidgetTest),
        ))

if __name__ == '__main__':
    unittest.main()




More information about the Zope3-Checkins mailing list