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


Python DummyRequest.GET方法代码示例

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


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

示例1: test_form_params

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import GET [as 别名]
    def test_form_params(self):
        from ptah.form.form import Form, DisplayForm

        request = DummyRequest()

        form = Form(None, request)
        disp_form = DisplayForm(None, request)

        self.assertEqual(form.method, 'post')

        post = {'post': 'info'}
        request.POST = post

        self.assertIs(form.form_params(), post)
        self.assertIs(disp_form.form_params(), DisplayForm.params)

        get = {'get': 'info'}
        request.GET = get
        form.method = 'get'
        self.assertIs(form.form_params(), get)

        form.method = 'unknown'
        self.assertEqual(form.form_params(), None)

        params = {'params': 'info'}
        form.method = 'POST'
        form.params = params
        self.assertIn('params', form.form_params().keys())
        self.assertIsInstance(form.form_params(), MultiDict)

        params = MultiDict({'params': 'info'})
        form.method = 'POST'
        form.params = params
        self.assertIs(form.form_params(), params)
开发者ID:webmaven,项目名称:ptah,代码行数:36,代码来源:test_form.py

示例2: test_PUT_using_GET_param

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import GET [as 别名]
 def test_PUT_using_GET_param(self):
     app = self._make_app()
     request = DummyRequest(method='POST')
     request.GET = {'$method': 'PUT'}
     request.POST = {'$method': 'DUMMY'}
     request.headers['X-HTTP-Method-Override'] = 'DUMMY'
     self._assert_before(request)
     app.registry.notify(NewRequest(request))
     self._assert_after(request, 'PUT')
开发者ID:antonygc,项目名称:pyramid_restler,代码行数:11,代码来源:tests.py

示例3: callView

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import GET [as 别名]
    def callView(self, config, path, matchdict=None, GET=None, POST=None, iface=None):
        from pyramid.router import Router
        from pyramid.testing import DummyRequest

        router = Router(config.registry)
        request = DummyRequest(path=path, registry=config.registry)
        request.matchdict = matchdict or {}
        if GET:
            request.GET = GET
        if POST:
            request.POST = POST
        if iface:
            directlyProvides(request, iface)
        return router.handle_request(request)
开发者ID:podhmo,项目名称:mokehehe,代码行数:16,代码来源:test_viewobject.py

示例4: test_form_params

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import GET [as 别名]
    def test_form_params(self):
        from ptah.form.form import Form, DisplayForm

        request = DummyRequest()

        form = Form(None, request)
        disp_form = DisplayForm(None, request)

        self.assertEqual(form.method, 'post')

        post = {'post': 'info'}
        request.POST = post

        self.assertIs(form.form_params(), post)
        self.assertIs(disp_form.form_params(), Form.params)

        get = {'get': 'info'}
        request.GET = get
        form.method = 'get'
        self.assertIs(form.form_params(), get)

        form.method = 'unknown'
        self.assertEqual(dict(form.form_params()), {})
开发者ID:runyaga,项目名称:ptah,代码行数:25,代码来源:test_form.py


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