【Flask Rest API 单元测试】
2021-03-31 17:27
标签:import 微信 content pre rdo https tps weixin big data Flask简单的Rest API 接口测试示例代码: 更多请关注微信公众号 【Flask Rest API 单元测试】 标签:import 微信 content pre rdo https tps weixin big data 原文地址:https://www.cnblogs.com/nelson2013/p/9251943.htmlimport unittest
import json
from app import app
class BasicTestCase(unittest.TestCase):
def setUp(self):
self.client = app.test_client()
self.client.testing = True
def tearDown(self):
""""""
pass
def test_logs_api(self):
""""""
book = {
"name": "Big Data Analysis",
"price": 58.5,
"category": "BigData"
}
uri = "/books"
result = self.client.post(uri, data=json.dumps(book), content_type=‘application/json‘)
self.assertEqual(result.status_code, 200)
if __name__ == ‘__main__‘:
unittest.main()
文章标题:【Flask Rest API 单元测试】
文章链接:http://soscw.com/index.php/essay/70553.html