test_http_utils.py 文件源码

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

项目:captaincloud 作者: bpsagar 项目源码 文件源码
def test_make_app(self):
        test = self.Test2(value=10)
        app = bottle_api.make_app(('/api', test))
        test_app = TestApp(app)

        params = {'arg1': 'test'}
        response = test_app.post(
            '/api/endpoint/', {'data': json.dumps(params)})
        expected_response = {
            'data': {'works': True, 'arg1': 'test', 'value': 10},
            'status': 'OK'
        }
        self.assertEqual(response.json, expected_response)

        params = {'arg1': 'error'}
        response = test_app.post(
            '/api/endpoint/', {'data': json.dumps(params)})
        expected_response = {
            'data': {},
            'status': 'ERROR'
        }
        self.assertEqual(response.json, expected_response)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号