- Timestamp:
- 2 Jun 2011, 10:23:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/utils/tests/test_converters.py
r6264 r6265 30 30 from zope.app.testing.functional import FunctionalTestCase 31 31 from zope.component.hooks import setSite, clearSite 32 from zope.formlib import form 32 33 from zope.interface.verify import verifyClass, verifyObject 33 34 … … 73 74 age = None 74 75 Contact = attrs_to_fields(Contact) 76 77 form_fields_select = form.Fields(IContact).select('name', 'vip') 78 form_fields_omit = form.Fields(IContact).omit('name', 'vip') 75 79 76 80 class ConverterTests(FunctionalTestCase): … … 193 197 dict(birthday='not-a-date'), contact) 194 198 self.assertEqual(err, [('birthday', u'Invalid datetime data')]) 199 200 def test_inject_formfields_select(self): 201 # We can use our own formfields and select only a subset of fields 202 contact = Contact() 203 converter = IObjectConverter(IContact) # a converter to IContact 204 input_data = dict(name='Bruno', age='99', vip='on') 205 err, inv_err, new_contact = converter.applyRowData( 206 input_data, contact, form_fields=form_fields_select) 207 self.assertEqual(contact.name, 'Bruno') 208 self.assertEqual(contact.age, 23) 209 self.assertEqual(contact.vip, True) 210 return 211 212 def test_inject_formfields_omit(self): 213 # We can use our own formfields and omit some fields 214 contact = Contact() 215 converter = IObjectConverter(IContact) # a converter to IContact 216 input_data = dict(name='Bruno', age='99', vip='on') 217 err, inv_err, new_contact = converter.applyRowData( 218 input_data, contact, form_fields=form_fields_omit) 219 self.assertEqual(contact.name, 'Manfred') 220 self.assertEqual(contact.age, 99) 221 self.assertEqual(contact.vip, False) 222 return 195 223 196 224 def test_suite():
Note: See TracChangeset for help on using the changeset viewer.