[Checkins] SVN: Sandbox/dirceu/megrok.form/src/megrok/form/
Spliting the widgets tests
Dirceu Pereira Tiegs
dirceutiegs at gmail.com
Tue Feb 19 16:51:18 EST 2008
Log message for revision 84065:
Spliting the widgets tests
Changed:
U Sandbox/dirceu/megrok.form/src/megrok/form/TODO.txt
U Sandbox/dirceu/megrok.form/src/megrok/form/tests/test_form.py
-=-
Modified: Sandbox/dirceu/megrok.form/src/megrok/form/TODO.txt
===================================================================
--- Sandbox/dirceu/megrok.form/src/megrok/form/TODO.txt 2008-02-19 19:25:08 UTC (rev 84064)
+++ Sandbox/dirceu/megrok.form/src/megrok/form/TODO.txt 2008-02-19 21:51:18 UTC (rev 84065)
@@ -2,11 +2,11 @@
megrok.form TODO
================
-- Get rid of megrok.form.browser.tzinfo
+- Release the egg
-- Add tests for all widgets (input and display)
+- Add input tests for all widgets
-- Release the egg
+- Get rid of megrok.form.browser.tzinfo
- Create a widget for zope.interface.schema.Time (based on z3c.widget.dropdowndatewidget)
Modified: Sandbox/dirceu/megrok.form/src/megrok/form/tests/test_form.py
===================================================================
--- Sandbox/dirceu/megrok.form/src/megrok/form/tests/test_form.py 2008-02-19 19:25:08 UTC (rev 84064)
+++ Sandbox/dirceu/megrok.form/src/megrok/form/tests/test_form.py 2008-02-19 21:51:18 UTC (rev 84065)
@@ -49,15 +49,32 @@
class MeGrokFormTests(unittest.TestCase):
def test_widgets(self):
"""
- Assures that the correct widgets are being used
-
- FIXME: This test sucks. Add a doctests for each widget.
+ Assures that all widgets are being rendered correctly.
"""
grok.grok('megrok.form.tests')
view = component.getMultiAdapter((MeGrokFormTest(), TestRequest()), name='addperson')
- rendered_html = u"""<html>\n<head>\n</head>\n\n<body>\n<form action="http://127.0.0.1" method="post"\n class="edit-form" enctype="multipart/form-data">\n\n \n\n \n\n <table class="form-fields">\n <tbody>\n \n <tr>\n <td class="label">\n \n <label for="form.name">\n <span class="required">*</span><span>Name</span>\n </label>\n </td>\n <td class="field">\n <div class="widget"><input class="textType" id="form.name" name="form.name" size="20" type="text" value="" /></div>\n \n </td>\n </tr>\n \n \n <tr>\n <td class="label">\n \n <label for="form.email">\n <span class="required">*</span><span>Email</span>\n </label>\n </td>\n <td class="field">\n <div class="widget"><input class="textType" id="form.email" name="form.email" size="20" type="text" value="" /></div>\n \n </td>\n </tr>\n \n \n <tr>\n <td class="label">\n \n <label for="form.picture">\n <span class="required">*</span><span>Picture</span>\n </label>\n </td>\n <td class="field">\n <div class="widget">\n\t<input type="hidden" value="" name="form.picture.used"\n id="form.picture.used" />\n\t\n\t\n\t<div>\n\t\t<input type="file" maxlength="True" class="" size="30"\n name="form.picture" id="form.picture" />\n\t\t\n\t</div>\n</div>\n \n </td>\n </tr>\n \n \n <tr>\n <td class="label">\n \n <label for="form.description">\n <span class="required">*</span><span>Description</span>\n </label>\n </td>\n <td class="field">\n <div class="widget"><textarea cols="60" id="form.description" name="form.description" rows="15" ></textarea><script type="text/javascript">\ntinyMCE.init({ \nmode : "exact", \nelements : "form.description"\n}\n);\n</script>\n</div>\n \n </td>\n </tr>\n \n \n <tr>\n <td class="label">\n \n <label for="form.birthday">\n <span class="required">*</span><span>Birthday</span>\n </label>\n </td>\n <td class="field">\n <div class="widget">\n<input class="textType" id="form.birthday" name="form.birthday" size="10" type="text" value="" />\n<input type="button" value="..." id="form.birthday_trigger">\n<script type="text/javascript">\n \n \n Calendar.setup({\n inputField: \'form.birthday\',\n button: \'form.birthday_trigger\',\n ifFormat: \'%Y-%m-%d\'\n});\n\n</script>\n</div>\n \n </td>\n </tr>\n \n \n <tr>\n <td class="label">\n \n <label for="form.resume">\n <span class="required">*</span><span>Resume</span>\n </label>\n </td>\n <td class="field">\n <div class="widget">\n\t<input type="hidden" value="" name="form.resume.used"\n id="form.resume.used" />\n\t\n\t\n\t<div>\n\t\t<input type="file" maxlength="True" class="" size="30"\n name="form.resume" id="form.resume" />\n\t\t\n\t</div>\n</div>\n \n </td>\n </tr>\n \n </tbody>\n </table>\n\n <div id="actionsView">\n <span class="actionButtons">\n <input type="submit" id="form.actions.41646420706572736f6e" name="form.actions.41646420706572736f6e" value="Add person" class="button" />\n </span>\n </div>\n</form>\n\n</body>\n</html>\n"""
- self.assertEquals(view.render(), rendered_html)
+ rendered_form = view.render()
+
+ # test rendered email widget
+ s = """<div class="widget"><input class="textType" id="form.email" name="form.email" size="20" type="text" value="" /></div>"""
+ assert(s in rendered_form)
+
+ # test rendered image widget
+ s = """<div class="widget">\n\t<input type="hidden" value="" name="form.picture.used"\n id="form.picture.used" />\n\t\n\t\n\t<div>\n\t\t<input type="file" maxlength="True" class="" size="30"\n name="form.picture" id="form.picture" />\n\t\t\n\t</div>\n</div>"""
+ assert(s in rendered_form)
+ # test rendered html widget
+ s = """<div class="widget"><textarea cols="60" id="form.description" name="form.description" rows="15" ></textarea><script type="text/javascript">\ntinyMCE.init({ \nmode : "exact", \nelements : "form.description"\n}\n);\n</script>\n</div>"""
+ assert(s in rendered_form)
+
+ # test rendered datetime widget
+ s = """<div class="widget">\n<input class="textType" id="form.birthday" name="form.birthday" size="10" type="text" value="" />\n<input type="button" value="..." id="form.birthday_trigger">\n<script type="text/javascript">\n \n \n Calendar.setup({\n inputField: \'form.birthday\',\n button: \'form.birthday_trigger\',\n ifFormat: \'%Y-%m-%d\'\n});\n\n</script>\n</div>"""
+ assert(s in rendered_form)
+
+ # test rendered file widget
+ s = """<div class="widget">\n\t<input type="hidden" value="" name="form.resume.used"\n id="form.resume.used" />\n\t\n\t\n\t<div>\n\t\t<input type="file" maxlength="True" class="" size="30"\n name="form.resume" id="form.resume" />\n\t\t\n\t</div>\n</div>"""
+ assert(s in rendered_form)
+
def test_email_default_constraint(self):
"""
Assures that the default constraint for the Email field is working
More information about the Checkins
mailing list