本文整理汇总了Python中googleapiclient.http.HttpRequest.to_json方法的典型用法代码示例。如果您正苦于以下问题:Python HttpRequest.to_json方法的具体用法?Python HttpRequest.to_json怎么用?Python HttpRequest.to_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类googleapiclient.http.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.to_json方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_http_request_to_from_json
# 需要导入模块: from googleapiclient.http import HttpRequest [as 别名]
# 或者: from googleapiclient.http.HttpRequest import to_json [as 别名]
def test_http_request_to_from_json(self):
def _postproc(*kwargs):
pass
http = httplib2.Http()
media_upload = MediaFileUpload(
datafile('small.png'), chunksize=500, resumable=True)
req = HttpRequest(
http,
_postproc,
'http://example.com',
method='POST',
body='{}',
headers={'content-type': 'multipart/related; boundary="---flubber"'},
methodId='foo',
resumable=media_upload)
json = req.to_json()
new_req = HttpRequest.from_json(json, http, _postproc)
self.assertEqual({'content-type':
'multipart/related; boundary="---flubber"'},
new_req.headers)
self.assertEqual('http://example.com', new_req.uri)
self.assertEqual('{}', new_req.body)
self.assertEqual(http, new_req.http)
self.assertEqual(media_upload.to_json(), new_req.resumable.to_json())
self.assertEqual(random.random, new_req._rand)
self.assertEqual(time.sleep, new_req._sleep)