

def test_enum(self):
    schema = schemas.EnumField.definition()
    definition = schema.deserialize({
        'name': 'state',
        'type': 'enum',
        'choices': ['on', 'off'],
    })
    validator = schemas.EnumField.validation(**definition)
    self.assertEquals('on', validator.deserialize('on'))
    self.assertRaises(colander.Invalid, validator.deserialize, '')
    self.assertRaises(colander.Invalid, validator.deserialize, 'ON')

dataset/ETHPy150Open spiral-project/daybed/daybed/tests/test_schemas_base.py BaseFieldsTests.test_enum/original