Changeset 6267 for main/waeup.sirp/trunk/src
- Timestamp:
- 2 Jun 2011, 12:14:53 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/utils/tests/test_converters.py
r6266 r6267 43 43 from waeup.sirp.utils.converters import IObjectConverter 44 44 from waeup.sirp.utils.helpers import attrs_to_fields 45 from waeup.sirp.interfaces import SimpleWAeUPVocabulary 46 47 colors = SimpleWAeUPVocabulary( 48 ('Red', u'red'), 49 ('Green', u'green'), 50 ('Blue', u'blue'), 51 ) 45 52 46 53 class IContact(Interface): … … 68 75 title = u'Birthday', 69 76 default = None, 77 ) 78 fav_color = schema.Choice( 79 title = u'Favourite color', 80 default = u'red', 81 vocabulary = colors, 70 82 ) 71 83 @invariant … … 255 267 # ...with the values from the dict set. 256 268 self.assertEqual(contact.name, 'Gabi') 269 return 270 271 def test_choice_vocab(self): 272 # We can handle vocabularies 273 converter = IObjectConverter(IContact) # a converter to IContact 274 err, inv_err, contact = converter.applyRowData( 275 dict(fav_color='blue'), 'contact') 276 assert contact.fav_color == u'blue' 277 assert isinstance(contact.fav_color, unicode) 278 return 279 280 def test_choice_vocab_invalid_value(self): 281 # We can handle vocabularies 282 converter = IObjectConverter(IContact) # a converter to IContact 283 err, inv_err, contact = converter.applyRowData( 284 dict(fav_color='magenta'), 'contact') 285 self.assertEqual(err, [('fav_color', u'Invalid value')]) 286 assert contact.fav_color == u'red' 257 287 return 258 288
Note: See TracChangeset for help on using the changeset viewer.