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


Python DummyRequest.context方法代码示例

本文整理汇总了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
开发者ID:enriquepablo,项目名称:eduid-dashboard,代码行数:9,代码来源:testing.py

示例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'
开发者ID:cdunklau,项目名称:paildocket,代码行数:9,代码来源:test_views.py

示例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)
开发者ID:sergeyv,项目名称:webapp,代码行数:12,代码来源:test_traversal.py

示例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
开发者ID:digideskio,项目名称:eduid-dashboard,代码行数:20,代码来源:testing.py

示例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)
开发者ID:ENCODE-DCC,项目名称:encoded,代码行数:25,代码来源:migrate_files_aws.py

示例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))
开发者ID:gjo,项目名称:kotti_tinymce,代码行数:7,代码来源:tests.py

示例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
开发者ID:SUNET,项目名称:eduid-signup,代码行数:8,代码来源:testing.py

示例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
开发者ID:Pylons,项目名称:cartouche,代码行数:8,代码来源:test_util.py


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