[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests - __init__.py:1.1.2.1 __init__.pyc:1.1.2.1 testBrowserWidget.py:1.1.2.1 testBrowserWidget.pyc:1.1.2.1 testTextWidget.py:1.1.2.1 testTextWidget.pyc:1.1.2.1
Stephan Richter
srichter@cbu.edu
Fri, 25 Jan 2002 09:11:13 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests
In directory cvs.zope.org:/tmp/cvs-serv20682/Formulator/Widgets/Browser/tests
Added Files:
Tag: Zope-3x-branch
__init__.py __init__.pyc testBrowserWidget.py
testBrowserWidget.pyc testTextWidget.py testTextWidget.pyc
Log Message:
- Initial check-in of the Formulator code
- Even though not everything works (specifically the widgets are in bad
shape), I am checking that stuff in, so that Jim, Martijn F. and I can
better work together.
- The FileEdit screen (which will be checked in in a minute) uses already
formulator.
- The validators are closed to finished.
- I think we have to rethink some of the design, simply because it is too
hard right now to create a field and a view for a property, even though
I provided already some handy methods. However Formulator does not
depend on Property-driven content objects.
- Please contact me (srichter@cbu.edu) or the Zope3 mailining list to
discuss issues and design.
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/__init__.pyc ===
-í
=N<c s d S( N( ( ( ( sK /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/__init__.pys ? s
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.py ===
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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()
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):
self.assertEqual(self._widget.render(),
'<input type="text" name="field_foo" value="Foo Value" />')
self.assertEqual(self._widget.render_hidden(),
'<input type="hidden" name="field_foo" value="Foo Value" />')
self._widget.extra = '''style="color: red"'''
self.assertEqual(self._widget.render_hidden(),
'<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/testBrowserWidget.pyc ===
-í
~sQ<c sĪ d k Z
d k l Z
d f d YZ d f d YZ & d e i f d YZ G d Z K e d j o L e i i
e n d S(
N( s Errorss
ContentObjectc s
d Z d Z RS( s# Class to provide a stub for a fieldc s d Sd S( s s Foo ValueN( ( s self( ( sT /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.pys getFoo s ( s __doc__s getFoo( ( ( sT /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.pys
ContentObject
s s Fieldc s/ d Z d Z d Z d Z RS( s Field Stub s fooc s | | _ d S( s N( s contexts selfs _context( s selfs context( ( sT /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.pys __init__ s c s ! | i i Sd S( s N( s selfs _contexts getFoo( s self( ( sT /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Bro!
wser/tests/testBrowserWidget.pys getPropertyInContext s ( s __doc__s ids __init__s getPropertyInContext( ( ( sT /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.pys Field s s Testc s) & ) d Z 1 d Z : d Z RS( Nc sG ) + d k l } , t } - t | } . | i | | _ d S( N( s
BrowserWidget( s# Zope.App.Formulator.Widgets.Browsers
BrowserWidgets
ContentObjects objs Fields fields selfs _widget( s selfs objs
BrowserWidgets field( ( sT /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.pys setUp) s c sĒ 1 3 | i | i i d d 4 | i | i i d d 5 | i | i i d d 6 | i | i i d d 7 | i | i i d d d S(
Ns tags inputs types texts cssClasss s hiddeni s extra( s selfs assertEquals _widgets getValue( s self( ( sT /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.pys testProperties1 s
c ss : < | i | i i = d ? | i | i i @ d B d | i _ C | i | i i D d d S( Ns9 <input type="text" name="field_foo" value="Foo Value" />s; <input type="hidden" name="field_foo" value="Foo Value" />s style="color: red"sM <input type="hidden" name="field_foo" value="Foo Value" style="color: red" />( s selfs assertEquals _widgets renders
render_hiddens extra( s self( ( sT /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.pys
testRendering: s
( s setUps testPropertiess
testRendering( ( ( sT /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.pys Test& s c s& G H t i } I | i t Sd S( N( s unittests
TestLoaders loaders loadTestsFromTestCases Test( s loader( ( sT /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.pys
test_suiteG s s __main__( s unittests Zope.App.Formulators Errorss
ContentObjects Fields TestCases Tests
test_suites __name__s TextTestRunners run( s Fields Errorss
test_suites Tests unittests
ContentObject( ( sT /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testBrowserWidget.pys ? s !
=== Added File Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.py ===
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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):
self.assertNotEqual(self._widget.render(), '')
self.assertNotEqual(self._widget.render_hidden(), '')
self._widget.extra = '''style="color: red"'''
self.assertNotEqual(self._widget.render_hidden(), '')
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.pyc ===
-í
=sQ<c sĪ d k Z
d k l Z
d f d YZ d f d YZ + d e i f d YZ I d Z M e d j o N e i i
e n d S(
N( s Errorss
ContentObjectc s
d Z d Z RS( s# Class to provide a stub for a fieldc s d Sd S( s s Foo ValueN( ( s self( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.pys getFoo s ( s __doc__s getFoo( ( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.pys
ContentObject
s s Fieldc s; d Z d Z d Z d Z % d Z RS( s Field Stub s fooc s | | _ d S( s N( s contexts selfs _context( s selfs context( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.pys __init__ s c s ! " | i i Sd S( s N( s selfs _contexts getFoo( s self( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/!
Browser/tests/testTextWidget.pys getPropertyInContext s c s % & ' t | | t Sd S( s N( s getattrs selfs names None( s selfs name( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.pys getValue% s ( s __doc__s ids __init__s getPropertyInContexts getValue( ( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.pys Field s
s Testc s) + . d Z 6 d Z > d Z RS( Nc sG . 0 d k l } 1 t } 2 t | } 3 | i | | _ d S( N( s
TextWidget( s# Zope.App.Formulator.Widgets.Browsers
TextWidgets
ContentObjects contents Fields fields selfs _widget( s selfs contents fields
TextWidget( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.pys setUp. s c s 6 8 | i | i i d d 9 | i | i i d d : | i | i i d d ; | i | i i d d d S( Ns extras s defaults displayWidthi s displayMaxWidth( s selfs assertEquals _widgets getValue( s self( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.pys testProperties6 s c sj > @ | i | i i d B | i | i i d D d | i _ E | i | i i d d S( Ns s style="color: red"( s selfs assertNotEquals _widgets renders
render_hiddens extra( s self( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.pys
testRendering> s ( s setUps testPropertiess
testRendering( !
( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.pys Test+ s c s& I J t i } K | i t Sd S( N( s unittests
TestLoaders loaders loadTestsFromTestCases Test( s loader( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.pys
test_suiteI s s __main__( s unittests Zope.App.Formulators Errorss
ContentObjects Fields TestCases Tests
test_suites __name__s TextTestRunners run( s Fields Errorss
test_suites Tests unittests
ContentObject( ( sQ /opt/Zope3/lib/python/Zope/App/Formulator/Widgets/Browser/tests/testTextWidget.pys ? s