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


Python http.HttpMockSequence方法代码示例

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


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

示例1: mock_google_sheets_responses

# 需要导入模块: from googleapiclient import http [as 别名]
# 或者: from googleapiclient.http import HttpMockSequence [as 别名]
def mock_google_sheets_responses(fixture_files=None):
    """
    Function to mock one or multiple requests to sheets.
    :param fixture_files: Fixture file name (must be located in the fixture folder).
    :return: An HttpMockSequence object.
    """
    mocks = [({'status': '200'}, open_fixture('discovery.json'))]

    # If input is a string, transform it into list of one item
    if isinstance(fixture_files, str):
        fixture_files = [fixture_files]

    # Add each fixture as a request mock if any
    if fixture_files:
        for file in fixture_files:
            mocks.append(({'status': '200'}, open_fixture(file)))
    http_mocks = HttpMockSequence(mocks)
    return http_mocks 
开发者ID:socialpoint-labs,项目名称:sheetfu,代码行数:20,代码来源:utils.py

示例2: _instrument_batch_messaging_service

# 需要导入模块: from googleapiclient import http [as 别名]
# 或者: from googleapiclient.http import HttpMockSequence [as 别名]
def _instrument_batch_messaging_service(self, app=None, status=200, payload=''):
        if not app:
            app = firebase_admin.get_app()
        fcm_service = messaging._get_messaging_service(app)
        if status == 200:
            content_type = 'multipart/mixed; boundary=boundary'
        else:
            content_type = 'application/json'
        fcm_service._transport = http.HttpMockSequence([
            ({'status': str(status), 'content-type': content_type}, payload),
        ])
        return fcm_service 
开发者ID:firebase,项目名称:firebase-admin-python,代码行数:14,代码来源:test_messaging.py

示例3: mock_http_response_sequence

# 需要导入模块: from googleapiclient import http [as 别名]
# 或者: from googleapiclient.http import HttpMockSequence [as 别名]
def mock_http_response_sequence(responses):
    """Set the mock response to an http request."""
    http_mock = http.HttpMockSequence(responses)
    _base_repository.LOCAL_THREAD.http = http_mock 
开发者ID:forseti-security,项目名称:forseti-security,代码行数:6,代码来源:http_mocks.py


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