[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests - __init__.py:1.1.4.1 testBrowserWidget.py:1.1.4.1 testTextWidget.py:1.1.4.1
Stephan Richter
srichter@cbu.edu
Mon, 1 Apr 2002 21:10:24 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv6377/Formulator/Widgets/Browser/tests
Added Files:
Tag: Zope-3x-branch
__init__.py testBrowserWidget.py testTextWidget.py
Log Message:
Issue 25: Resolved by janko & srichter
This checkin fixes all the license headers of all the files that needed
fixing it. :) This was made possible by Janko Hauser's script, which is now
available in the ZopeRoot/utilities directory.
Also, cleaned up the Formualtor tag insanity!
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/__init__.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
"""
$Id: testBrowserWidget.py,v 1.1.4.1 2002/04/02 02:10:23 srichter Exp $
"""
import unittest
from Zope.App.Formulator import Errors
class ContentObject:
"""Class to provide a stub for a field"""
def getFoo(self):
""" """
return "Foo Value"
class Field:
"""Field Stub """
id = 'foo'
def __init__(self, context):
""" """
self._context = context
def getPropertyInContext(self):
""" """
return self._context.getFoo()
class Test(unittest.TestCase):
def setUp(self):
from Zope.App.Formulator.Widgets.Browser import BrowserWidget
obj = ContentObject()
field = Field(obj)
self._widget = BrowserWidget.BrowserWidget(field)
def testProperties(self):
self.assertEqual(self._widget.getValue('tag'), 'input')
self.assertEqual(self._widget.getValue('type'), 'text')
self.assertEqual(self._widget.getValue('cssClass'), '')
self.assertEqual(self._widget.getValue('hidden'), 0)
self.assertEqual(self._widget.getValue('extra'), '')
def testRendering(self):
request = {'field_foo': 'Foo Value'}
self.assertEqual(self._widget.render(request),
'<input type="text" name="field_foo" '
'value="Foo Value" />')
self.assertEqual(self._widget.render_hidden(request),
'<input type="hidden" name="field_foo" '
'value="Foo Value" />')
self._widget.extra = '''style="color: red"'''
self.assertEqual(self._widget.render_hidden(request),
'<input type="hidden" name="field_foo" '
'value="Foo Value" style="color: red" />')
def test_suite():
loader = unittest.TestLoader()
return loader.loadTestsFromTestCase( Test )
if __name__=='__main__':
unittest.TextTestRunner().run( test_suite() )
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
import unittest
from Zope.App.Formulator import Errors
class ContentObject:
"""Class to provide a stub for a field"""
def getFoo(self):
""" """
return "Foo Value"
class Field:
"""Field Stub """
id = 'foo'
def __init__(self, context):
""" """
self._context = context
def getPropertyInContext(self):
""" """
return self._context.getFoo()
def getValue(self, name):
""" """
return getattr(self, name, None)
class Test(unittest.TestCase):
def setUp(self):
from Zope.App.Formulator.Widgets.Browser import TextWidget
content = ContentObject()
field = Field(content)
self._widget = TextWidget.TextWidget(field)
def testProperties(self):
self.assertEqual(self._widget.getValue('extra'), '')
self.assertEqual(self._widget.getValue('default'), '')
self.assertEqual(self._widget.getValue('displayWidth'), 20)
self.assertEqual(self._widget.getValue('displayMaxWidth'), '')
def testRendering(self):
request = {'field_foo': 'Foo Value'}
self.assertNotEqual(self._widget.render(request), '')
self.assertNotEqual(self._widget.render_hidden(request), '')
self._widget.extra = '''style="color: red"'''
self.assertNotEqual(self._widget.render_hidden(request), '')
def test_suite():
loader = unittest.TestLoader()
return loader.loadTestsFromTestCase( Test )
if __name__=='__main__':
unittest.TextTestRunner().run( test_suite() )