def test_baidu(self): longin = get_xls('xls_name.xlsx', 'Sheet1') list_num = len(longin) for i in range(list_num): url = longin[i][2] methon = longin[i][1] username = longin[i][3] passwd = longin[i][4] header = {'content-type': 'application/json'} long_params = ConfigHttp() long_params.set_url(url) long_params.set_headers(header) parms = {'user_id': username, 'email': username} data = {'email': username, 'password': passwd} long_params.set_params(parms) long_params.set_data(data) print(url, methon, username, passwd) if methon == 'post': long_params.post() print(long_params.post().status_code) elif methon == 'get': long_params.get() print(long_params.get().status_code) else: print("end")
def test_matchStation_error(self): request = ConfigHttp() data = self.data_list[1] if data[1].lower() == 'post': request.set_url(data[2]) request.set_headers({ "content-type": "application/x-www-form-urlencoded;charset=utf-8" }) request.set_data({"lng": data[3], "lat": data[4]}) response = request.post() response_json = response.json() code = response_json.get('code') message = response_json.get('message') print(code, message) self.assertEqual(code, int(data[5])) self.assertEqual(message, data[6])
# 返回集群的领导者 # curl -w '\n' http://10.11.3.105:7601/leader # cfh.url = "http://10.11.3.105:7601/leader" # print(cfh.get().json()) # 加车 # curl --header "Content-Type: application/json" --request POST --data '{"type":"carinfo","data":["LA81F1HT3FA000030,20111111111111111130,11111111,京P5QV20,402882e0607944c801607cd988725d6d,,4028819d5b18f617015b192e432b011d,,,402882d25ddea6c7015ddeacf8700087,402882d25c0eeeed015c101333940ef3,,,2018-01-16 16:57:11,2018-05-13 14:21:50,1","LA81F1HT3FA000021,21222222222222222222222222222,京P5QV20,402882e0607944c801607cd988725d6d,,4028819d5b18f617015b192e432b011d,,,402882d25ddea6c7015ddeacf8700087,402882d25c0eeeed015c101333940ef3,,,2018-01-16 16:57:11,2018-05-13 14:21:50,1"]}' http://10.11.3.104:7000/batch data = { "type": "carinfo", "data": [ "LLLLF1HT3FA000030,20111111111111111130,11111111,\ 京P5QV20,402882e0607944c801607cd988725d6d,,4028819d5b18f617015b192e432b011d,,,\ 402882d25ddea6c7015ddeacf8700087,402882d25c0eeeed015c101333940ef3,,,\ 2018-01-16 16:57:11,2018-05-13 14:21:50,1", "LLLLF1HT3FA000021,21222222222222222222222222222,\ 京P5QV20,402882e0607944c801607cd988725d6d,,4028819d5b18f617015b192e432b011d,,,\ 402882d25ddea6c7015ddeacf8700087,402882d25c0eeeed015c101333940ef3,,,\ 2018-01-16 16:57:11,2018-05-13 14:21:50,1" ] } cfh.url = "http://10.11.3.104:5000/batch" cfh.set_data(json.dumps(data)) cfh.set_headers(headers) jsondata = cfh.post().json() print(jsondata) # 获取车辆信息 # curl -w ‘\n’ http://10.11.3.104:7000/carinfo?vin=LA81F1HT3FA000030 # 删车 # curl -w '\n' http://10.11.3.106:7000/delete?type=carinfo\&field=LA81F1HT3FA000030
from common.commons import Readkey import readConfig red = readConfig.ReadConfig() http = ConfigHttp() log = Logger() logger = log.get_logger() keys = Readkey() try: value = keys.get_xls('login.xlsx', 'user') user_phone = int(value[0][0]) user_password = int(value[0][1]) http.set_data( data={ 'lang': 'zh-CN', 'userId': '', 'token': '', 'companyId': '', 'country': '', 'phone': user_phone, 'password': user_password }) http.set_url('/sysUser/login') ts = http.post().json() for key, vl in ts['datas'].items(): # 写入到配置文件 red.set_user(str(key), str(vl)) except Exception as e: logger.error('this is get_token %s' % e)