123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- 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, '', '')
- def test4(self):
- data = {"name": "p_00x32cx6bo7_count", "data": [
- {"action_type": "曝光", "session_id": "xx12x@p_00x32cx6bo7\\x0368d1cfc7236659285e932ff64c13e5a8\\x03exp_id",
- "action_value": "exposure"},
- {"action_type": "曝光", "session_id": "xx12x@p_00x32cx6bo7\\x0368d1cfc7236659285e932ff64c13e5a8\\x03exp_id",
- "action_value": "exposure"},
- {"action_type": "曝光", "session_id": "xx12x@p_00x32cx6bo7\\x0368d1cfc7236659285e932ff64c13e5a8\\x03exp_id",
- "action_value": "exposure"},
- {"action_type": "曝光", "session_id": "xx12x@p_00x32cx6bo7\\x0368d1cfc7236659285e932ff64c13e5a8\\x03exp_id",
- "action_value": "exposure"}]}
- url = "http://10.20.2.200:31669/api/hao_rec/about_log/log_counter"
- for x in range(100):
- res = requests.post(url, json=data)
- print(res.text)
|