示例#1
0
    def test_string_validator(self):
        v = String()
        self.assertEqual("foo", v.validate("foo"))
        with self.assertRaises(ValidationError) as c:
            v.validate(1)

        self.assertEqual("Expected str got int instead.", str(c.exception))
示例#2
0
    def test_string_validator_max_len_kw(self):
        v = String(max_len=3)
        self.assertEqual("foo", v.validate("foo"))
        with self.assertRaises(ValidationError) as c:
            v.validate("foobar")

        self.assertEqual("String exceeds max length of 3.", str(c.exception))
示例#3
0
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"))
示例#4
0
    def test_string_validator(self):
        v = String()
        self.assertEqual("foo", v.validate("foo"))
        with self.assertRaises(ValidationError) as c:
            v.validate(1)

        self.assertEqual("Expected str got int instead.", str(c.exception))
示例#5
0
    def test_string_validator_max_len_kw(self):
        v = String(max_len=3)
        self.assertEqual("foo", v.validate("foo"))
        with self.assertRaises(ValidationError) as c:
            v.validate("foobar")

        self.assertEqual("String exceeds max length of 3.", str(c.exception))
示例#6
0
    def test_string_validator_min_len_kw(self):
        v = String(min_len=3)

        with self.assertRaises(ValidationError) as c:
            v.validate("fo")

        self.assertEqual("String must be at least length 3.", str(c.exception))
示例#7
0
    def test_string_validator_min_len_kw(self):
        v = String(min_len=3)

        with self.assertRaises(ValidationError) as c:
            v.validate("fo")

        self.assertEqual("String must be at least length 3.", str(c.exception))
示例#8
0
class _Notification(ObjectSchema):
    SignatureVersion = String()
    Timestamp = String()
    Signature = String()
    Type = String()
    SigningCertURL = String()
    MessageId = String()
    Message = String()
    UnsubscribeURL = String()
    TopicArn = String()
    Subject = String()
示例#9
0
    def test_create(self):
        schema_cls = ObjectSchema.create("MySchema", {
            "first-name": String(),
            "last-name": String(optional=True)
        })

        self.assertEqual(type(schema_cls), SchemaMeta)
        self.assertIsInstance(schema_cls(), ObjectSchema)

        with self.assertRaises(ValidationError) as c:
            schema_cls().validate({'first-name': 1})

        self.assertIn('first-name', c.exception.errors)
示例#10
0
文件: model.py 项目: supritha/dr_blog
class Schema(ObjectSchema):
    title = String(min_len=1)
    thumbnail = String(min_len=1)
    body = String(min_len=1)

    #author = String(min_len=1)

    def get_defaults(self):
        return {
            'id': uuid.uuid4().hex,
            'created_at': time.time(),
            'updated_at': time.time()
        }
示例#11
0
 class JobSchema(ObjectSchema):
     title = String()
     id = EnsureType(Foo)
示例#12
0
class AddressSchema(ObjectSchema):
    number = Integer()
    street = String()
    suburb = String()
示例#13
0
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()
示例#14
0
 class PersonSchema(ObjectSchema):
     first_name = String()
     last_name = String()
     id = Integer()
     test = Float()
示例#15
0
 class JobSchema(ObjectSchema):
     title = String()
     id = Integer()
示例#16
0
 class BarSchema(BaseSchema):
     bar = String()
示例#17
0
 class BaseSchema(ObjectSchema):
     foo = String()
示例#18
0
 class PersonSchema(ObjectSchema):
     first_name = String()
     last_name = String(optional=True)
示例#19
0
 class PersonSchema(ObjectSchema):
     first_name = String()
     last_name = String()
     job = EnsureType("Job")
示例#20
0
class JobSchema(ObjectSchema):
    role = String()
    active = Boolean(default=True)
示例#21
0
 class PersonSchema(ObjectSchema):
     first_name = String()
     last_name = String()
示例#22
0
 class PersonSchema(ObjectSchema):
     species = String(default="Human")
     first_name = String()
     last_name = String()
示例#23
0
 class TestRequestSchema(ObjectSchema):
     request_guid = String()
     players = List(EnsureType("Person"))