예제 #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"))