Ignore:
Timestamp:
2 Jun 2011, 12:23:28 (13 years ago)
Author:
uli
Message:

Test converter with vocabs with non-string values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/tests/test_converters.py

    r6267 r6268  
    5050    ('Blue', u'blue'),
    5151    )
    52 
     52car_nums = SimpleWAeUPVocabulary(
     53    ('None', 0),
     54    ('One', 1),
     55    ('Two', 2),
     56    ('Three', 3),
     57    )
    5358class IContact(Interface):
    5459    """Sample interface for sample content type used here in tests.
     
    8085        default = u'red',
    8186        vocabulary = colors,
     87        )
     88    num_cars = schema.Choice(
     89        title = u'Number of cars owned',
     90        default = None,
     91        vocabulary = car_nums,
    8292        )
    8393    @invariant
     
    285295        self.assertEqual(err, [('fav_color', u'Invalid value')])
    286296        assert contact.fav_color == u'red'
     297        return
     298
     299    def test_non_string_choice(self):
     300        # We can handle vocabs with non-string values
     301        converter = IObjectConverter(IContact) # a converter to IContact
     302        err, inv_err, contact = converter.applyRowData(
     303            dict(num_cars='1'), 'contact')
     304        assert contact.num_cars == 1
    287305        return
    288306
Note: See TracChangeset for help on using the changeset viewer.