예제 #1
0
def send_request(data):
    """
    再次封装请求
    :param data: 测试用例
    :return:
    """
    if data["request_type"] == 'post':
        if data["file"]:
            result = post(header=data["headers"],
                          address=data["http_type"] + "://" + data["host"] +
                          data["address"],
                          timeout=data["timeout"])
    # elif data["request_type"] == 'get':
    #     result = get(header=data["headers"], address=data["http_type"] + "://" + data["host"] + data["address"],
    #                  data=data["parameter"], timeout=data["timeout"])
    # elif data["request_type"] == "put":
    #     if data["file"]:
    #         result = put(header=data["headers"],
    #                      address=data["http_type"] + "://" + data["host"] + data["address"],
    #                      request_parameter_type=data["parameter_type"], files=data["parameter"],
    #                      timeout=data["timeout"])
    #     else:
    #         result = put(header=data["headers"], address=data["http_type"] + "://" + data["host"] + data["address"],
    #                      request_parameter_type=data["parameter_type"], data=data["parameter"],
    #                      timeout=data["timeout"])
    # elif data["request_type"] == "delete":
    #     result = delete(header=data["headers"], address=data["http_type"] + "://" + data["host"] + data["address"],
    #                     data=data["parameter"], timeout=data["timeout"])
    else:
        return False, False
    return result
예제 #2
0
def appStopCharge(heards,data):
    try:
        status_code, result,response_time = post(header=heards, address=data["address"], data=data["data"])
        inster_stop_result(bill_pay_no=data["data"]["billPayNo"],resultCode=result["resultCode"],test_id=data["test_id"],response_time=response_time)
        print(status_code,result)
    except Exception as e:
        print(e)

# if __name__ == '__main__':
예제 #3
0
def appQueryState(heards,data):
    try:
        while True:
            status_code, result,response_time = post(header=heards, address=data["address"], data=data["data"])
            if result["resultCode"] == "00000":
                inster_querystate_result(data=json.dumps(result["data"]), bill_pay_no=data["data"]["billPayNo"],resultCode=result["resultCode"], test_id=data["test_id"],response_time=response_time)
            time.sleep(3)
            if result["resultCode"] != "00000":
                inster_querystate_result(data=json.dumps(result["data"]),bill_pay_no=data["data"]["billPayNo"],resultCode=result["resultCode"],test_id=data["test_id"],response_time=response_time)
                break
    except Exception as e:
        print(e)
예제 #4
0
def query_token(heards,data):
    try:
        status_code, result,response_time = post(header=heards, address=data["address"],data=data["data"])
        result_data = result['Data']
        result_data_decrypt = AES_Decrypt(key=data["datasecret"], vi=data["datasecretiv"], data=result_data)
        result_data_decrypt_json = json.loads(result_data_decrypt)
        AccessToken = result_data_decrypt_json['AccessToken']
        print('status_code:%s\n' % status_code + 'token result:%s\n' % result + '解密数据%s\n' % result_data_decrypt_json)
        mysql_data = query_token_result(data["opertorid"])
        if mysql_data == '':
            inster_token_result(operator_id=data["opertorid"],token_result=AccessToken)
        elif mysql_data['token_result'] == AccessToken:
            pass
        elif mysql_data['token_result'] != AccessToken:
            update_token_reslut(data["opertorid"],AccessToken)
    except Exception as e:
        print(e)
        raise failureException("token失败")
예제 #5
0
def query_equip_business_policy(heards,data):
    try:
        status_code, result,response_time = post(header=heards, address=data["address"], data=data["data"])
        if result['Ret']==4002:
            token_fail_re_token(url=data["url"], data=data)
            token_result = query_token_result(data["opertorid"])['token_result']
            if token_result == "":
                token_fail_re_token(url=data["url"], data=data)
            bear = "Bearer " + token_result
            heards_charge = {"Content-Type": "application/json", "Authorization": bear}
            query_stop_charge(heards=heards_charge,data=data)
        elif result['Ret']==0:
            result_data = result['Data']
            result_data_decrypt = AES_Decrypt(key=data["datasecret"], vi=data["datasecretiv"], data=result_data)
            result_data_decrypt_json = json.loads(result_data_decrypt)
            print('status_code:%s\n'%status_code + 'token result:%s\n'%result + '解密数据%s\n'%result_data_decrypt_json)
    except Exception as e:
        print('充电桩业务策略逻辑失败')
        raise failureException("充电桩业务策略逻辑失败")
예제 #6
0
def appStartCharge(heards,data):
    try:
        write_data = {"id":data["test_id"],
                      "post_data":data['data'],
                      "bill_pay_no":"",
                      "resultCode":""}
        status_code, result,response_time = post(header=heards, address=data["address"], data=data["data"])
        print(status_code,result)
        if 'resultCode' in result:
            if result["resultCode"] == '00000':
                billPayNo = result["data"]["billPayNo"]
                write_data["bill_pay_no"] = billPayNo
                write_data['resultCode'] = result['resultCode']
                return write_data,response_time
            else:
                write_data["bill_pay_no"] = ''
                write_data['resultCode'] = result['resultCode']
                return write_data,response_time
        else:
            return write_data,response_time
    except Exception as e:
        return e