コード例 #1
0
    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")
コード例 #2
0
ファイル: test_user.py プロジェクト: soldiers1989/Waka
 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)
コード例 #3
0
    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])
コード例 #4
0
ファイル: testcluster.py プロジェクト: heartsmoking/ApiTest
# 返回集群的领导者
# 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
コード例 #5
0
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)
コード例 #6
0
ファイル: head_config.py プロジェクト: yandeqing/apitest
        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)