class SampleEntity(Entity): string_field = StringField() string_field_w_default = StringField('default') integer_field = IntField() integer_field_w_default = IntField(42) enum_field = EnumField(ChooseOne) enum_field_w_default = EnumField(ChooseOne, ChooseOne.B) list_field = ListField(string_types, ['alpha', 'beta', 'gamma'])
class DerivedSampleEntity(SampleEntity): string_field_w_default = StringField('new_default') choice = EnumField(ChooseOne, required=False) new_field = IntField() enum_field = ChooseOne.A def __init__(self, new_field, **kwargs): super(DerivedSampleEntity, self).__init__(new_field=new_field, **kwargs)
def test_unassigned_name_throws_error(self): field = IntField() with ExpectedException(AttributeError): field.name class Clazz(object): int_field = IntField() clazz = Clazz() with ExpectedException(AttributeError): clazz.int_field
class PackageSpec(Entity): """ pyside-1.1.2-py27_1 zlib-1.2.7-1 """ channel = StringField() name = StringField() version = StringField() build = StringField() build_number = IntField() platform = EnumField(Platform) arch = EnumField(Arch)
class Clazz(Entity): int_field = IntField(required=False, nullable=True)
class Clazz(Entity): int_field = IntField('18')
class Clazz(object): int_field = IntField()
class Patch(Entity): filename = StringField() url = StringField() patch_level = IntField(default=0)