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_sendH5(self): path = "/wkStRoute/api/sms/sendH5" post_parm = {"phoneNo": "18610660297", "validate": "001897f346018a61da3a46034203f6e9"} response = ConfigHttp() response.set_url(self.url+path) response.set_headers(self.header) response.set_data(post_parm) print(self.url+path) results = ConfigHttp.post_origi(response)
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])
def test_hardware_version_03(self): test_case = test_cases[2] logger.info(test_case[0]) ch = ConfigHttp() url = test_case[2] params = {"ip": test_case[4], "password": test_case[5]} ch.set_url(url) ch.set_params(params) result = ch.get().json() try: self.assertEqual(result['status'], int(test_case[7]), test_case[0] + ":测试失败,status错误") self.assertEqual(result['data'], ast.literal_eval(test_case[8]), test_case[0] + ":测试失败,data错误") self.assertEqual(result['operation'], test_case[9], test_case[0] + ":测试失败,operation错误") self.assertEqual(result['msg'], test_case[10], test_case[0] + ":测试失败,msg错误") except Exception as ex: logger.error(str(ex) + "\n实际返回内容:" + str(result))
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)
to 查询结束时间戳 秒 topoIds(可选) <=10个 该数组为空或不填时默认所有业务系统进行查询 streamIds(可选) 流ID数组 多个以','隔开 <=10个 该数组为空或不填时默认对所有流进行查询 monitorLevels(可选) 告警级别数组 支持查询EMERGENCY(严重)、HIGH(高)、MEDIUM(中) 、LOW(低) 选填,该数组为空或不填时默认不对告警级别条件加限制 monitorTypes(可选) 告警类型数组 暂时只支持FIXED_THRESHOLD(静态阈值)、COMBINE(复合关联)两个条件(支持条件内多个).选填, 该数组为空或不填时为默认不对告警类型条件加以限制 targetMetrics(可选) 暂时只支持_count(交易量)、_response_rate(响应率)、_no_response_count(交易未响应数)、 _success_rate(交易成功率)、_fail_count(交易失败数)、_latency_msec(交易响应时间)、customized(其他) 7个条件进行(支持条件内多个),选填,该数组为空或不填时为默认不对告警指标条件加以限制 ''' # from=1526956200&to=1526958000& # streamIds[]=5afc0e19e4b054b2b5d14499& # groupByField=_trans_ref.TermNum& # targetMetrics[]=_success_rate,_response_rate&sortMetric=_success_rate params['from'] = "1528974940" params['to'] = "1528975260" params['streamIds[]'] = "5afe3bf3e4b054b2b5d5581c," params['topoIds[]'] = "" params['monitorLevels[]'] = "" params['monitorTypes'] = "FIXED_THRESHOLD" params['targetMetrics[]'] = "_count,_success_rate,_response_rate" # params['topN'] = "228" # # 组成get请求用的params cfh.set_params(params) url = "/ezsonar/apm/restDataApi/getTermsTopNData" cfh.set_url(url) rsp = cfh.get() print(rsp)
once = "once=" + MD5Util.md5s(config.get_headers("client_key")) + timestamp + ";" developkey = "developkey=" + config.get_headers("develop_key") return timestampstr + oauth2Str + signatureStr + secret + once + developkey @staticmethod def create_signature(confighttp, timestamp, request_method): content = HeadConfig.get_requestParams(confighttp, request_method) # type:ConfigHttp request_url = "request_url=" + confighttp.path + "&" contentstr = "content=" + content + "&" request_method = "request_method=" + request_method + "&" timestampstr = "timestamp=" + timestamp + "&" config = ReadConfig() secret = config.get_headers("secret") if secret == '': secret = "secret=" + MD5Util.md5s(timestamp) else: secret = "secret=" + secret timestampstr_secret = request_url + contentstr + request_method + timestampstr + secret return MD5Util.md5s(timestampstr_secret) if __name__ == '__main__': configHttp = ConfigHttp() configHttp.set_url("biz/users/login") configHttp.set_data({"account": "*****@*****.**", "password": "******", "source": "app"}) timestamp = "1553137347" authorization = HeadConfig.get_authorization(configHttp, "post", timestamp) print(authorization)