test_api.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:maas 作者: maas 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号