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

Class HttpRequestMock

googleapiclient/http.py:1609–1638  ·  view source on GitHub ↗

Mock of HttpRequest. Do not construct directly, instead use RequestMockBuilder.

Source from the content-addressed store, hash-verified

1607
1608
1609class HttpRequestMock(object):
1610 """Mock of HttpRequest.
1611
1612 Do not construct directly, instead use RequestMockBuilder.
1613 """
1614
1615 def __init__(self, resp, content, postproc):
1616 """Constructor for HttpRequestMock
1617
1618 Args:
1619 resp: httplib2.Response, the response to emulate coming from the request
1620 content: string, the response body
1621 postproc: callable, the post processing function usually supplied by
1622 the model class. See model.JsonModel.response() as an example.
1623 """
1624 self.resp = resp
1625 self.content = content
1626 self.postproc = postproc
1627 if resp is None:
1628 self.resp = httplib2.Response({"status": 200, "reason": "OK"})
1629 if "reason" in self.resp:
1630 self.resp.reason = self.resp["reason"]
1631
1632 def execute(self, http=None):
1633 """Execute the request.
1634
1635 Same behavior as HttpRequest.execute(), but the response is
1636 mocked and not really from an HTTP request/response.
1637 """
1638 return self.postproc(self.resp, self.content)
1639
1640
1641class RequestMockBuilder(object):

Callers 1

__call__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…