Skip to content

Commit

Permalink
Add a test for Kai Groner fix.
Browse files Browse the repository at this point in the history
This fixes #54.
  • Loading branch information
kiorky committed Dec 7, 2011
1 parent 0adcb83 commit 688858e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Next release

- Update to lingua for translations, add french translation

- fix issue #54.

0.9.3 (2011-08-10)
------------------

Expand Down
33 changes: 30 additions & 3 deletions deform/tests/test_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class TestForm(unittest.TestCase):
def _makeOne(self, schema, **kw):
from deform.form import Form
return Form(schema, **kw)

def test_ctor_buttons_strings(self):
from deform.widget import FormWidget
schema = DummySchema()
Expand Down Expand Up @@ -49,6 +49,33 @@ def test_ctor_passes_unknown_kwargs(self):
self.assertEqual(child.a, 'a')
self.assertEqual(child.b, 'b')


class TestIssues(unittest.TestCase):

def test_issue_54(self):
import deform
import colander
class LoginForm(colander.Schema):
username = colander.SchemaNode(colander.String())
password = colander.SchemaNode(colander.String(),
widget=deform.widget.PasswordWidget())
def validate_password(node, d):
raise colander.Invalid(node,
'Username does not match password')
loginform = LoginForm(validator=validate_password)
data = [('__formid__', 'deform'),
('username', 'kai'),
('password', '123')]
try:
deform.Form(loginform).validate(data)
except deform.ValidationFailure, e:
rendered = e.render()
self.assertTrue(
'<p class="errorMsg">'
'Username does not match password'
'</p>' in rendered
)

class TestButton(unittest.TestCase):
def _makeOne(self, **kw):
from deform.form import Button
Expand All @@ -70,9 +97,9 @@ def test_name_with_space(self):
button = self._makeOne(name="log\tin as a user")
self.assertEquals(button.name, 'log_in_as_a_user')
self.assertEquals(button.value, 'log_in_as_a_user')

def test_ctor(self):
button = self._makeOne(name='name', title='title',
button = self._makeOne(name='name', title='title',
type='type', value='value', disabled=True)
self.assertEqual(button.value, 'value')
self.assertEqual(button.name, 'name')
Expand Down

0 comments on commit 688858e

Please sign in to comment.