示例#1
0
    def test_source(self, mocker):
        req = mocker.Mock(['args', 'headers', 'values'])
        req.args = {'foo': 'bar'}
        req.headers = {'baz': 'bat'}
        arg = Argument('foo', location=['args'])
        assert arg.source(req) == MultiDict(req.args)

        arg = Argument('foo', location=['headers'])
        assert arg.source(req) == MultiDict(req.headers)
示例#2
0
 def test_source_default_location(self, mocker):
     req = mocker.Mock(['values'])
     req._get_child_mock = lambda **kwargs: MultiDict()
     arg = Argument('foo')
     assert arg.source(req) == req.values
示例#3
0
 def test_source_bad_location(self, mocker):
     req = mocker.Mock(['values'])
     arg = Argument('foo', location=['foo'])
     assert len(arg.source(req)) == 0  # yes, basically you don't find it