class TestModel(BaseModel): class TestEnum(Enum): value_1 = 1 value_2 = '2' value_3 = date(year=2015, month=7, day=30) test_string_field_1 = StringIdField(name='other_field') test_int_field_1 = IntegerField() test_datetime = DateTimeField(parse_format="%Y-%m-%dT%H:%M:%S") test_array_datetime = ArrayField(field_type=DateTimeField( parse_format="%Y-%m-%dT%H:%M:%S")) test_array_multitype = ArrayField(field_type=MultiTypeField(field_types=[ IntegerField(), DateTimeField(parse_format="%Y-%m-%dT%H:%M:%S") ])) test_model_field_1 = ArrayField(field_type=ArrayField( field_type=ModelField())) test_hash_map = HashMapField(field_type=DateField( parse_format="%Y-%m-%d date")) test_timedelta = TimedeltaField() test_enum = EnumField(enum_class=TestEnum) test_multi_field = MultiTypeField(field_types=[ IntegerField(), DateField(parse_format="%Y-%m-%d multi date") ])
def test_integer_field_modified(self): list_model = ListModel([1, 2], field_type=IntegerField()) list_model.flat_data() list_model.append(3) self._assert_equal_after_pickle(list_model)
class Paging(BaseModel): offset = IntegerField(default=0) limit = IntegerField(default=100)
class PicklableModel(BaseModel): int_field = IntegerField()
class Model(BaseModel): test_int = IntegerField() test_array = ArrayField(field_type=MultiTypeField( field_types=[IntegerField(), ModelField()]))
def test_sort(self): test_list = ListModel(["one", "two", 1, 2, 9, 3, "three", []], field_type=IntegerField()) test_list.sort() self.assertEqual([1, 2, 3, 9], list(test_list))