当前位置: 首页>>代码示例>>Python>>正文


Python Request.from_values方法代码示例

本文整理汇总了Python中werkzeug.wrappers.Request.from_values方法的典型用法代码示例。如果您正苦于以下问题:Python Request.from_values方法的具体用法?Python Request.from_values怎么用?Python Request.from_values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.wrappers.Request的用法示例。


在下文中一共展示了Request.from_values方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_wrapper_support

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_wrapper_support(self):
        req = Request.from_values()
        resp = Response()
        c = EncryptedCookie.load_cookie(req, crypter_or_keys_location=KEYS_DIR)
        assert c.new
        c['foo'] = 42
        assert c.crypter is not None
        c.save_cookie(resp)

        req = Request.from_values(headers={
            'Cookie':  'session="%s"' % parse_cookie(resp.headers['set-cookie'])['session']
        })
        c2 = EncryptedCookie.load_cookie(req, crypter_or_keys_location=KEYS_DIR)
        assert not c2.new
        assert c2 == c
开发者ID:saltycrane,项目名称:flask-encryptedsession,代码行数:17,代码来源:test_encryptedcookie.py

示例2: test_wrapper_support

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
def test_wrapper_support():
    req = Request.from_values()
    resp = Response()
    c = SecureCookie.load_cookie(req, secret_key=b'foo')
    assert c.new
    c['foo'] = 42
    assert c.secret_key == b'foo'
    c.save_cookie(resp)

    req = Request.from_values(headers={
        'Cookie':  'session="%s"' % parse_cookie(resp.headers['set-cookie'])['session']
    })
    c2 = SecureCookie.load_cookie(req, secret_key=b'foo')
    assert not c2.new
    assert c2 == c
开发者ID:brunoais,项目名称:werkzeug,代码行数:17,代码来源:test_securecookie.py

示例3: test_wrapper_support

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_wrapper_support(self):
        req = Request.from_values()
        resp = Response()
        c = SecureCookie.load_cookie(req, secret_key="foo")
        assert c.new
        c["foo"] = 42
        assert c.secret_key == "foo"
        c.save_cookie(resp)

        req = Request.from_values(
            headers={"Cookie": 'session="%s"' % parse_cookie(resp.headers["set-cookie"])["session"]}
        )
        c2 = SecureCookie.load_cookie(req, secret_key="foo")
        assert not c2.new
        assert c2 == c
开发者ID:FakeSherlock,项目名称:Report,代码行数:17,代码来源:securecookie.py

示例4: test_large_file

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
 def test_large_file(self):
     data = 'x' * (1024 * 600)
     req = Request.from_values(data={'foo': (StringIO(data), 'test.txt')},
                               method='POST')
     # make sure we have a real file here, because we expect to be
     # on the disk.  > 1024 * 500
     self.assert_(isinstance(req.files['foo'].stream, file))
开发者ID:y2bishop2y,项目名称:microengine,代码行数:9,代码来源:formparser.py

示例5: test_parse_unicode

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_parse_unicode(self):
        req = Request.from_values('/bubble?foo=barß')
        parser = RequestParser()
        parser.add_argument('foo')

        args = parser.parse_args(req)
        self.assertEqual(args['foo'], 'barß')
开发者ID:aaronbenz,项目名称:flask-restplus,代码行数:9,代码来源:test_reqparse.py

示例6: test_passing_arguments_object

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_passing_arguments_object(self):
        req = Request.from_values('/bubble?foo=bar')
        parser = RequestParser()
        parser.add_argument(Argument('foo'))

        args = parser.parse_args(req)
        self.assertEqual(args['foo'], 'bar')
开发者ID:aaronbenz,项目名称:flask-restplus,代码行数:9,代码来源:test_reqparse.py

示例7: test_parse_required

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_parse_required(self):
        with self.app.app_context():
            req = Request.from_values('/bubble')

            parser = RequestParser()
            parser.add_argument('foo', required=True, location='values')

            expected = {
                'foo': 'Missing required parameter in the post body or the query string'
            }
            try:
                parser.parse_args(req)
            except BadRequest as e:
                self.assertEqual(e.data['message'], 'Input payload validation failed')
                self.assertEqual(e.data['errors'], expected)

            parser = RequestParser()
            parser.add_argument('bar', required=True, location=['values', 'cookies'])

            expected = {
                'bar': ("Missing required parameter in the post body or the query "
                "string or the request's cookies")
            }
            try:
                parser.parse_args(req)
            except BadRequest as e:
                self.assertEqual(e.data['message'], 'Input payload validation failed')
                self.assertEqual(e.data['errors'], expected)
开发者ID:aaronbenz,项目名称:flask-restplus,代码行数:30,代码来源:test_reqparse.py

示例8: test_parse_lte

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_parse_lte(self):
        req = Request.from_values('/bubble?foo<=bar')
        parser = RequestParser()
        parser.add_argument('foo', operators=['<='])

        args = parser.parse_args(req)
        self.assertEqual(args['foo'], 'bar')
开发者ID:aaronbenz,项目名称:flask-restplus,代码行数:9,代码来源:test_reqparse.py

示例9: test_parse_required

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_parse_required(self):
        req = Request.from_values("/bubble")

        parser = RequestParser()
        parser.add_argument("foo", required=True)

        self.assertRaises(exceptions.BadRequest, lambda: parser.parse_args(req))
开发者ID:JosefJezek,项目名称:flask-restful,代码行数:9,代码来源:test_reqparse.py

示例10: test_parse_required

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_parse_required(self):
        app = Flask(__name__)
        with app.app_context():
            req = Request.from_values("/bubble")

            parser = RequestParser()
            parser.add_argument("foo", required=True, location='values')

            message = ''
            try:
                parser.parse_args(req)
            except exceptions.BadRequest as e:
                message = e.data['message']

            self.assertEquals(message, ({'foo': 'Missing required parameter in '
                                                'the post body or the query '
                                                'string'}))

            parser = RequestParser()
            parser.add_argument("bar", required=True, location=['values', 'cookies'])

            try:
                parser.parse_args(req)
            except exceptions.BadRequest as e:
                message = e.data['message']
            self.assertEquals(message, ({'bar': 'Missing required parameter in '
                                                'the post body or the query '
                                                'string or the request\'s '
                                                'cookies'}))
开发者ID:lynx-ua,项目名称:flask-restful,代码行数:31,代码来源:test_reqparse.py

示例11: test_parse_foo_operators_four_hunderd

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_parse_foo_operators_four_hunderd(self):
        app = Flask(__name__)
        with app.app_context():
            parser = RequestParser()
            parser.add_argument("foo", type=int),

            self.assertRaises(exceptions.BadRequest, lambda: parser.parse_args(Request.from_values("/bubble?foo=bar")))
开发者ID:lynx-ua,项目名称:flask-restful,代码行数:9,代码来源:test_reqparse.py

示例12: test_parse_unicode

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_parse_unicode(self):
        req = Request.from_values("/bubble?foo=barß")
        parser = RequestParser()
        parser.add_argument("foo")

        args = parser.parse_args(req)
        self.assertEquals(args['foo'], u"barß")
开发者ID:RexKang,项目名称:flask-restful,代码行数:9,代码来源:test_reqparse.py

示例13: test_passing_arguments_object

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_passing_arguments_object(self):
        req = Request.from_values("/bubble?foo=bar")
        parser = RequestParser()
        parser.add_argument(Argument("foo", type=str))

        args = parser.parse_args(req)
        self.assertEquals(args['foo'], u"bar")
开发者ID:RexKang,项目名称:flask-restful,代码行数:9,代码来源:test_reqparse.py

示例14: test_passing_arguments_object

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_passing_arguments_object(self, app):
        req = Request.from_values('/bubble?foo=bar')
        parser = RequestParser()
        parser.add_argument(Argument('foo'))

        args = parser.parse_args(req)
        assert args['foo'] == 'bar'
开发者ID:bedge,项目名称:flask-restplus,代码行数:9,代码来源:test_reqparse.py

示例15: test_parse_choices_sensitive

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import from_values [as 别名]
    def test_parse_choices_sensitive(self):
        req = Request.from_values("/bubble?foo=BAT")

        parser = RequestParser()
        parser.add_argument("foo", choices=["bat"], case_sensitive=True),

        self.assertRaises(exceptions.BadRequest, lambda: parser.parse_args(req))
开发者ID:RexKang,项目名称:flask-restful,代码行数:9,代码来源:test_reqparse.py


注:本文中的werkzeug.wrappers.Request.from_values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。