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

Method test_bad_response

tests/test_json_model.py:205–223  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

203 )
204
205 def test_bad_response(self):
206 model = JsonModel(data_wrapper=False)
207 resp = httplib2.Response({"status": "401"})
208 resp.reason = "Unauthorized"
209 content = b'{"error": {"message": "not authorized"}}'
210
211 try:
212 content = model.response(resp, content)
213 self.fail("Should have thrown an exception")
214 except HttpError as e:
215 self.assertTrue("not authorized" in str(e))
216
217 resp["content-type"] = "application/json"
218
219 try:
220 content = model.response(resp, content)
221 self.fail("Should have thrown an exception")
222 except HttpError as e:
223 self.assertTrue("not authorized" in str(e))
224
225 def test_good_response(self):
226 model = JsonModel(data_wrapper=True)

Callers

nothing calls this directly

Calls 2

JsonModelClass · 0.90
responseMethod · 0.45

Tested by

no test coverage detected