class PersonSchema(ObjectSchema): id = Integer() name = String() dob = DateTime(format='%Y-%m-%dT%H:%M:%S') title = String(optional=True) address = EnsureType("Address") jobs = List(EnsureType("Job"))
def test_integer_validator(self): v = Integer() self.assertEqual(v.validate(42), 42) with self.assertRaises(ValidationError) as c: v.validate("foo") self.assertEqual("Expected int got str instead.", str(c.exception))
class _Message(ObjectSchema): StatusCode = String() AutoScalingGroupARN = String() Description = String() Service = String() Details = Dict(String()) AutoScalingGroupName = String() ActivityId = String() AccountId = String() RequestId = String() StartTime = DateTime(format='%Y-%m-%dT%H:%M:%S.%f') Time = DateTime(format='%Y-%m-%dT%H:%M:%S.%f') Progress = Integer() EndTime = DateTime(format='%Y-%m-%dT%H:%M:%S.%f') Cause = String() Event = String() StatusMessage = String() EC2InstanceId = String()
def test_nullable_is_true(self): v = Integer(nullable=True) self.assertEqual(None, v.validate(None))
class PersonSchema(ObjectSchema): first_name = String() last_name = String() id = Integer() test = Float()
class JobSchema(ObjectSchema): title = String() id = Integer()
class AddressSchema(ObjectSchema): number = Integer() street = String() suburb = String()