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


Python DummyRequest.headers['X-CSRF-Token']方法代码示例

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


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

示例1: req

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers['X-CSRF-Token'] [as 别名]
def req(db_session):
    """
    (Integration Testing) Creates a dummy request

    The request is setup with configuration CSRF values and the expected
    ``db_session`` property, the goal being to be be as close to a real
    database session as possible.

    Note that we must called it "req" as "request" is reserved by pytest.

    :param db_session: The testing database session

    :returns: a configured request object
    """
    import uuid
    import mock
    from pyramid.testing import DummyRequest

    dummy_request = DummyRequest()

    # Configurable csrf token
    csrf_token = str(uuid.uuid4())
    get_csrf_token = mock.Mock(return_value=csrf_token)
    dummy_request.session.get_csrf_token = get_csrf_token
    dummy_request.headers['X-CSRF-Token'] = csrf_token

    # Attach database session for expected behavior
    dummy_request.db_session = db_session
    db_session.info['request'] = dummy_request

    return dummy_request
开发者ID:jkrooskos,项目名称:occams_lims,代码行数:33,代码来源:conftest.py

示例2: csrf_request

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers['X-CSRF-Token'] [as 别名]
def csrf_request(config):
    request = DummyRequest(registry=config.registry)
    request.headers['X-CSRF-Token'] = request.session.get_csrf_token()
    return request
开发者ID:juli-so,项目名称:h,代码行数:6,代码来源:schemas_test.py

示例3: csrf_request

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import headers['X-CSRF-Token'] [as 别名]
def csrf_request(config, **kwargs):
    request = DummyRequest(db=mock.sentinel.db_session, registry=config.registry, **kwargs)
    request.headers['X-CSRF-Token'] = request.session.get_csrf_token()
    return request
开发者ID:ficolo,项目名称:h,代码行数:6,代码来源:schemas_test.py


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