def test_init(self): """Test successful Dict Field initialization""" add_info = Auto() assert add_info is not None value = add_info._load(1) assert value == 1
def __create_id_field(new_class): """Create and return a default ID field that is Auto generated""" id_field = Auto(identifier=True) setattr(new_class, "id", id_field) id_field.__set_name__(new_class, "id") setattr(new_class, _ID_FIELD_NAME, id_field.field_name) field_objects = getattr(new_class, _FIELDS) field_objects["id"] = id_field setattr(new_class, _FIELDS, field_objects)
class PersonAdded(BaseEvent): id = Auto(identifier=True) first_name = String(max_length=50, required=True) last_name = String(max_length=50, required=True) age = Integer(default=21) class Meta: aggregate_cls = Person
class PersonAutoSSN(BaseView): ssn = Auto(identifier=True) first_name = String(max_length=50, required=True) last_name = String(max_length=50) age = Integer(default=21)
class AutoTest(BaseView): identifier = Auto(identifier=True) auto_field1 = Auto()
class AutoTest(BaseAggregate): auto_field = Auto(identifier=True)
class AutoTest(BaseAggregate): auto_field = Auto(increment=True)
class AutoTest(BaseAggregate): auto_field1 = Auto() auto_field2 = Auto()
def test_validation(self): """Test validation for the Auto Field""" add_info = Auto(required=True) add_info._load(None)
def test_that_auto_fields_that_are_identifiers_are_also_unique(self): message_id = Auto(identifier=True) assert message_id.identifier is True assert message_id.unique is True
class PersonAutoSSN(BaseAggregate): ssn = Auto(identifier=True) name = String(max_length=25)