本文整理汇总了Python中pyramid.testing.DummyRequest.context方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.context方法的具体用法?Python DummyRequest.context怎么用?Python DummyRequest.context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.testing.DummyRequest
的用法示例。
在下文中一共展示了DummyRequest.context方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dummy_request
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import context [as 别名]
def dummy_request(self):
request = DummyRequest()
request.context = DummyResource()
request.userdb = self.userdb
request.db = self.db
request.registry.settings = self.settings
return request
示例2: test_forbidden_view_without_user_returns_redirect_to_login
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import context [as 别名]
def test_forbidden_view_without_user_returns_redirect_to_login():
from paildocket.views.root import forbidden
request = DummyRequest()
request.user = False
request.context = DummyResource()
response = forbidden(request)
assert urlparse(response.location).path == '/login'
示例3: test_resource_form_traversal
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import context [as 别名]
def test_resource_form_traversal():
result = traverse(_root, "/rest/schools/%s/@view" % SCHOOL_ID)
context = result['context']
request = DummyRequest(params={})
request.context = context
from webapp.views.rest import json_rest_get_f
result = json_rest_get_f(context, request)
assert(result['id'] == SCHOOL_ID)
示例4: dummy_request
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import context [as 别名]
def dummy_request(self, cookies={}):
request = DummyRequest()
request.context = DummyResource()
request.userdb = self.userdb
request.userdb_new = self.userdb_new
request.db = self.db
request.registry.settings = self.settings
def propagate_user_changes(user):
"""
Make sure there is a request.context.propagate_user_changes in testing too.
"""
logger.debug('FREDRIK: Testing dummy_request.context propagate_user_changes')
return self.request.amrelay.request_sync(user)
request.context.propagate_user_changes = propagate_user_changes
return request
示例5: run
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import context [as 别名]
def run(app, files):
root = app.root_factory(app)
collection = root['file']
dummy_request = DummyRequest(root=root, registry=app.registry, _stats={})
manager.push({'request': dummy_request, 'registry': app.registry})
for i, uuid in enumerate(collection):
item = root.get_by_uuid(uuid)
dummy_request.context = item
properties = item.upgrade_properties()
sheets = None
value = files.get(str(uuid))
if value is not None:
properties['file_size'] = value['file_size']
sheets = {
'external': {
'service': 's3',
'bucket': 'encode-files',
'key': value['s3_file_name'],
},
}
item.update(properties, sheets=sheets)
if (i + 1) % 100 == 0:
logger.info('Updated %d', i + 1)
示例6: call
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import context [as 别名]
def call(self, context):
from kotti_tinymce.settings import get_settings_json
request = DummyRequest()
request.context = context
return json.loads(get_settings_json(request))
示例7: dummy_request
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import context [as 别名]
def dummy_request(self, cookies={}):
request = DummyRequest()
request.context = DummyResource()
request.signup_userdb = self.signup_userdb
request.registry.settings = self.settings
return request
示例8: _makeRequest
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import context [as 别名]
def _makeRequest(self, **kw):
from pyramid.testing import DummyModel
from pyramid.testing import DummyRequest
request = DummyRequest(**kw)
request.context = DummyModel()
return request