import json import unittest import requests def print_json_pretty(obj): print(json.dumps(obj, indent=4, ensure_ascii=False)) def print_json_plain(obj): print(json.dumps(obj, ensure_ascii=False)) def req(url, json_dict): res = requests.post(url, json=json_dict, headers={ "cookie": "lang=zh-CN; MJSESSIONID=YmQ1YTAyOTktMjBiMy00MmZhLWJmMmUtNjQyODJmYjU0ODM4; satoken-server=d6e42d1a-2372-4746-a032-f5690ff6fbbc"}) print_json_plain(json_dict) print_json_pretty(res.json()) class MyTest(unittest.TestCase): def test1(self): json_dict = { "name": "wwW", "type": "MYSQL", "description": "dolor dolor tempor", "ip": "eip-mysql-2.qa.mlamp.cn", "port": 3306, "index_name": "", "db_name": "hao_rec_pro", "userName": "hao_rec", "passwd": "Hao_rec@123456" } req("http://127.0.0.1:8500/ui/datasource/newDataSource", json_dict) # 测试死锁 def test2(self): req(1, '粉底液', '祛痘') req(1, '眼霜', '修护') # 测试兜底策略 def test3(self): req(1, '', '')