def test_fetch_api_description_not_okay(self):
# If the response is not 200 OK, fetch_api_description throws toys.
content = factory.make_name("content")
request = self.patch(httplib2.Http, "request")
response = httplib2.Response({})
response.status = http.client.BAD_REQUEST
response.reason = http.client.responses[http.client.BAD_REQUEST]
request.return_value = response, json.dumps(content)
error = self.assertRaises(
CommandError, api.fetch_api_description,
"http://example.com/api/2.0/")
error_expected = "%d %s:\n%s" % (
http.client.BAD_REQUEST,
http.client.responses[http.client.BAD_REQUEST],
json.dumps(content))
self.assertEqual(error_expected, "%s" % error)
评论列表
文章目录