示例#1
0
def test_source_vaa_scheme():
    class MarshMallowScheme(marshmallow.Schema):
        x = marshmallow.fields.Str()

    @deal.pre(vaa.marshmallow(MarshMallowScheme))
    def identity(x):
        return x

    with pytest.raises(deal.ContractError) as exc_info:
        identity(-2)
    assert exc_info.value.source.startswith(
        '<vaa._external.Marshmallow object at ')
    exp = "[Error(message='Not a valid string.', field='x')] (where x=-2)"
    state.color = False
    assert str(exc_info.value) == exp
    state.color = True
示例#2
0
文件: tests.py 项目: aleien/deal
    def setUp(self):
        class _Scheme(marshmallow.Schema):
            name = marshmallow.fields.Str()

        self.Scheme = vaa.marshmallow(_Scheme)
示例#3
0
文件: post.py 项目: life4/vaa
import marshmallow
import pyschemes

import vaa


class PostMarshmallow(marshmallow.Schema):
    name = marshmallow.fields.Str(required=True)
    mail = marshmallow.fields.Email(required=True)
    count = marshmallow.fields.Int(required=True)


post_pyschemes = pyschemes.Scheme({
    'name': str,
    'mail': str,
    'count': int,
})

postmodels = [
    PostMarshmallow,
    post_pyschemes,
]

postvalidators = [
    vaa.marshmallow(PostMarshmallow),
    vaa.pyschemes(post_pyschemes),
]