test_wsgi.py 文件源码

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

项目:glare 作者: openstack 项目源码 文件源码
def test_http_error_response_codes(self):
        """Makes sure v1 unallowed methods return 405"""
        unallowed_methods = [
            ('/schemas', ['PUT', 'DELETE', 'HEAD', 'PATCH', 'POST']),
            ('/schemas/type_name', ['PUT', 'DELETE', 'HEAD', 'PATCH', 'POST']),
            ('/artifacts/type_name', ['PUT', 'DELETE', 'HEAD', 'PATCH']),
            ('/artifacts/type_name/artifact_id', ['PUT', 'HEAD', 'POST']),
            ('/artifacts/type_name/artifact_id/blob)name',
             ['HEAD', 'PATCH', 'POST']),
        ]
        api = router.API(routes.Mapper())
        for uri, methods in unallowed_methods:
            for method in methods:
                req = webob.Request.blank(uri)
                req.method = method
                res = req.get_response(api)
                self.assertEqual(http.METHOD_NOT_ALLOWED, res.status_int)

        # Makes sure not implemented methods return 405
        req = webob.Request.blank('/schemas/image')
        req.method = 'NonexistentMethod'
        res = req.get_response(api)
        self.assertEqual(http.METHOD_NOT_ALLOWED, res.status_int)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号