Example #1
0
 def test_existing(self):
     request = TestRequest()
     widget = TupleSequenceWidget(
         self.field, self.field.value_type, request)
     widget.setRenderedValue((u'existing',))
     self.failIf(widget.hasInput())
     self.assertRaises(MissingInputError, widget.getInputValue)
     check_list = (
         'checkbox', 'field.foo.remove_0', 'input', 'field.foo.0.bar',
             'existing',
         'submit', 'submit', 'field.foo.add',
         'field.foo.count" value="1"',
     )
     self.verifyResult(widget(), check_list, inorder=True)
     widget.setRenderedValue((u'existing', u'second'))
     self.failIf(widget.hasInput())
     self.assertRaises(MissingInputError, widget.getInputValue)
     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)
Example #2
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!',))
Example #3
0
 def test_new(self):
     request = TestRequest()
     widget = TupleSequenceWidget(
         self.field, self.field.value_type, request)
     self.failIf(widget.hasInput())
     self.assertRaises(MissingInputError, widget.getInputValue)
     check_list = ('input', 'name="field.foo.add"')
     self.verifyResult(widget(), check_list)
Example #4
0
 def test_add(self):
     request = TestRequest(form={'field.foo.add': u'Add bar',
                                 'field.foo.count': u'0'})
     widget = TupleSequenceWidget(
         self.field, self.field.value_type, request)
     self.assert_(widget.hasInput())
     self.assertRaises(WidgetInputError, widget.getInputValue)
     check_list = (
         'checkbox', 'field.foo.remove_0', 'input', 'field.foo.0.bar',
         'submit', 'submit', 'field.foo.add'
     )
     self.verifyResult(widget(), check_list, inorder=True)