Beispiel #1
0
 def test_request(self):
     request = TestRequest(form={'field.foo.0.bar': u'Hello world!',
                                 'field.foo.count': u'1'})
     widget = TupleSequenceWidget(
         self.field, self.field.value_type, request)
     self.assert_(widget.hasInput())
     self.assertEquals(widget.getInputValue(), (u'Hello world!',))
Beispiel #2
0
 def test_remove(self):
     request = TestRequest(form={
         'field.foo.remove_0': u'1',
         'field.foo.0.bar': u'existing', 'field.foo.1.bar': u'second',
         'field.foo.remove': u'Remove selected items',
         'field.foo.count': u'2'})
     widget = TupleSequenceWidget(
         self.field, self.field.value_type, request)
     widget.setRenderedValue((u'existing', u'second'))
     self.assertEquals(widget.getInputValue(), (u'second',))
     check_list = (
         'checkbox', 'field.foo.remove_0', 'input', 'field.foo.0.bar',
             'existing',
         'checkbox', 'field.foo.remove_1', 'input', 'field.foo.1.bar',
             'second',
         'submit', 'submit', 'field.foo.add',
         'field.foo.count" value="2"',
     )
     self.verifyResult(widget(), check_list, inorder=True)