當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。