本文整理汇总了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
示例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
示例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