本文整理汇总了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)
示例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')
示例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)
示例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()), {})