Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added a test for multiple select (introduced in #92 of deform) #7

Merged
merged 1 commit into from

2 participants

John Anderson Mathieu Le Marec - Pasquet
John Anderson

No description provided.

Mathieu Le Marec - Pasquet
Collaborator

THX !

Mathieu Le Marec - Pasquet kiorky merged commit 7afab84 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 37 additions and 0 deletions.
  1. +17 −0 deformdemo/__init__.py
  2. +20 −0 deformdemo/test.py
17 deformdemo/__init__.py
View
@@ -998,6 +998,23 @@ class Schema(colander.Schema):
form = deform.Form(schema, buttons=('submit',))
return self.render_form(form)
+ @view_config(renderer='templates/form.pt', name='select_with_multiple')
+ @demonstrate('Select Widget (with mulitple)')
+ def select_with_multiple(self):
+ choices = (('habanero', 'Habanero'),
+ ('jalapeno', 'Jalapeno'),
+ ('chipotle', 'Chipotle'))
+
+ class Schema(colander.Schema):
+ pepper = colander.SchemaNode(
+ deform.Set(),
+ widget=deform.widget.SelectWidget(values=choices,
+ multiple=True)
+ )
+ schema = Schema()
+ form = deform.Form(schema, buttons=('submit',))
+ return self.render_form(form)
+
@view_config(renderer='templates/form.pt', name='select_with_deferred')
@demonstrate('Select Widget (with deferred choices and default)')
def select_with_deferred(self):
20 deformdemo/test.py
View
@@ -1885,6 +1885,26 @@ class SelectWidgetWithUnicodeTests(SelectWidgetTests):
u"{'pepper': u'\\u30cf\\u30d0\\u30cd\\u30ed'}",
)
+class SelectWidgetMultipleTests(Base, unittest.TestCase):
+ url = '/select_with_multiple/'
+
+ def test_submit_selected(self):
+ browser.open(self.url)
+ browser.wait_for_page_to_load("30000")
+
+ captured_default = "{'pepper': set([u'habanero', u'chipotle'])}"
+
+ browser.add_selection('deformField1', 'index=0')
+ browser.add_selection('deformField1', 'index=2')
+
+ browser.click('submit')
+ browser.wait_for_page_to_load("30000")
+
+ captured = browser.get_text('css=#captured')
+
+ self.assertFalse(browser.is_element_present('css=.errorMsgLbl'))
+ self.assertEqual(captured, captured_default)
+
class SelectWidgetIntegerTests(Base, unittest.TestCase):
url = '/select_integer/'
def test_render_default(self):
Something went wrong with that request. Please try again.