MCPcopy Index your code
hub / github.com/googleapis/google-api-python-client / HttpMock

Class HttpMock

googleapiclient/http.py:1723–1762  ·  view source on GitHub ↗

Mock of httplib2.Http

Source from the content-addressed store, hash-verified

1721
1722
1723class HttpMock(object):
1724 """Mock of httplib2.Http"""
1725
1726 def __init__(self, filename=None, headers=None):
1727 """
1728 Args:
1729 filename: string, absolute filename to read response from
1730 headers: dict, header to return with response
1731 """
1732 if headers is None:
1733 headers = {"status": "200"}
1734 if filename:
1735 with open(filename, "rb") as f:
1736 self.data = f.read()
1737 else:
1738 self.data = None
1739 self.response_headers = headers
1740 self.headers = None
1741 self.uri = None
1742 self.method = None
1743 self.body = None
1744 self.headers = None
1745
1746 def request(
1747 self,
1748 uri,
1749 method="GET",
1750 body=None,
1751 headers=None,
1752 redirections=1,
1753 connection_type=None,
1754 ):
1755 self.uri = uri
1756 self.method = method
1757 self.body = body
1758 self.headers = headers
1759 return httplib2.Response(self.response_headers), self.data
1760
1761 def close(self):
1762 return None
1763
1764
1765class HttpMockSequence(object):

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…