Skip to content

Commit

Permalink
Unit test fe validator and required css
Browse files Browse the repository at this point in the history
  • Loading branch information
paj committed Jul 27, 2010
1 parent 58bea34 commit 84434ba
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from cStringIO import StringIO
from tw2.core import EmptyField, IntValidator, ValidationError
from cgi import FieldStorage
import formencode

import webob
if hasattr(webob, 'NestedMultiDict'):
Expand Down Expand Up @@ -425,6 +426,40 @@ class TestTableLayout(WidgetTest):
</table>"""
declarative = True

def test_required(self):
attrs = {'children': [TextField(id='field1', validator=twc.Required)]}
expected = """<table>
<tr class="odd required" id="field1:container">
<th>Field1</th>
<td>
<input name="field1" id="field1" type="text">
<span id="field1:error"></span>
</td>
</tr></table>"""

def test_fe_not_required(self):
attrs = {'children': [TextField(id='field1', validator=formencode.FancyValidator(not_empty=False))]}
expected = """<table>
<tr class="odd" id="field1:container">
<th>Field1</th>
<td>
<input name="field1" id="field1" type="text">
<span id="field1:error"></span>
</td>
</tr></table>"""

def test_fe_required(self):
attrs = {'children': [TextField(id='field1', validator=formencode.FancyValidator(not_empty=True))]}
expected = """<table>
<tr class="odd required" id="field1:container">
<th>Field1</th>
<td>
<input name="field1" id="field1" type="text">
<span id="field1:error"></span>
</td>
</tr></table>"""


class TestRowLayout(WidgetTest):
widget = RowLayout
attrs = {'children': [TextField(id='field1'),
Expand Down

0 comments on commit 84434ba

Please sign in to comment.