Exemplo n.º 1
0
def per_sell_case(request):
    """
    每条销售测试用例的数据处理fixture:完成数据的组装、请求的发送和响应数据的返回
    :param request: 代表每条销售测试用例
    :return:
    """

    # 销售测试用例请求数据的组装:因常规玩法和特殊玩法测试数据来源于不同的表,所以需要分别处理
    sell_content = {
        "RunCode": basic_data.serial_num_gen(),
        "UserId": basic_data.user_id,
        "AccessType": 2,
        "PlayEname": "",
        "SellTermCode": "",
        "LoginSession": session['RespContent']['LoginSession'],
        "Money": "",
        "DrawWay": 1,
        "TicketCode": "",
        "CheckCode": ""
    }
    # 长周期数据和快乐8数据来自不同的表:快乐8玩法的玩法名、金额和投注号码
    if 'play_ename' in request.param:
        sell_content.update(PlayEname=request.param['play_ename'])
        sell_content.update(Money=str(request.param['bet_money']))
        sell_content.update(TicketCode=request.param['bet_code'])
        if sell_content['PlayEname'] == 'ZCKL8':
            sell_content.update(SellTermCode=basic_data.k8_term_code)
    # 长周期数据和快乐8数据来自不同的表:长周期玩法销售用例的玩法名、金额和投注号码
    if 'playEname' in request.param:
        sell_content.update(PlayEname=request.param['playEname'])
        sell_content.update(Money=request.param['money'])
        sell_content.update(TicketCode=request.param['code'])
        if sell_content['PlayEname'] == 'B001':
            sell_content.update(SellTermCode=basic_data.ball_term_code)
        if sell_content['PlayEname'] == 'S3':
            sell_content.update(SellTermCode=basic_data.d3_term_code)
        if sell_content['PlayEname'] == 'QL730':
            sell_content.update(SellTermCode=basic_data.QL730_term_code)

    # 计算验证码并更新请求数据中的对应值
    check_code = Toolkit.check_code(sell_content['RunCode'] +
                                    general_out_content['PartnerId'] +
                                    sell_content['UserId'] +
                                    sell_content['TicketCode'] +
                                    str(sell_content['Money']) +
                                    sell_content['LoginSession'])
    sell_content.update(Checkcode=check_code)
    general_out_content.update(ReqContent=sell_content)

    # 发送销售请求并接收返回值
    recv = Toolkit.send_and_recv(
        basic_data.sell_profix_url + basic_data.partner_id +
        '&hashType=md5&hash=', 'sell', general_out_content)
    # 返回数据库中得到的原始销售记录、服务器返回值和销售期号给销售测试函数
    return request.param, recv, sell_content['SellTermCode']
 def time_stamp_gen(cls):
     # 生成服务器时间时间戳
     time_req = {
         "PartnerId": basic_data.partner_id,
         "TimeStamp": basic_data.current_time(),
         "SerialNum": basic_data.serial_num_gen(),
         "Version": basic_data.version,
         "Token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
         "ReqContent": {}
     }
     recv = Toolkit.send_and_recv(
         basic_data.time_sync_profix_url + basic_data.partner_id +
         '&hashType=md5&hash=', 'time', time_req)
     return recv["RespContent"]['SysDateTime']
Exemplo n.º 3
0
def test_time_sync():
    time_sync_json = {
        "PartnerId": basic_data.partner_id,
        "TimeStamp": basic_data.current_time(),
        "SerialNum": basic_data.serial_num_gen(),
        "Version": basic_data.version,
        "Token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "ReqContent": {}
    }
    rcv_time = Toolkit.send_and_recv(
        basic_data.time_sync_profix_url + basic_data.partner_id +
        '&hashType=md5&hash=', "time", time_sync_json)
    # print(rcv_time['RespContent']['SysDateTime'])
    logging.info("test_time_sync获取到服务器返回")
    assert rcv_time != 0
 def session_id(cls):
     server_time_stamp = Toolkit.time_stamp_gen()
     req_content = {
         "PartnerId": basic_data.partner_id,
         "TimeStamp": server_time_stamp,
         "SerialNum": basic_data.serial_num_gen(),
         "Version": basic_data.version,
         "Token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
         "ReqContent": {
             "Userid": "",
             "LoginPass": "",
             "LoginType": "",
             "MacAddress": ""
         }
     }
     req_content['ReqContent']["Userid"] = basic_data.user_id
     req_content['ReqContent']["LoginPass"] = basic_data.login_pass
     req_content['ReqContent']["MacAddress"] = basic_data.mac_address
     req_content['ReqContent']["LoginType"] = basic_data.login_type
     # print('req_content:', req_content)
     logging.info("登录开始")
     return Toolkit.send_and_recv(
         basic_data.login_profix_url + basic_data.partner_id +
         '&hashType=md5&hash=', 'login', req_content)
Exemplo n.º 5
0
    每个查询测试用例的id构造函数
    :param item:
    :return:
    """
    return item['PlayEname'] + '_' + item['SellTermCode'] + '_' + item[
        'Runcode']


# 单例模式:运行一次测试只有一个session_id,而不是每个测试用例都去进行登录获取session_id,因此调用同一个对象获取相同的sessionId
session = Toolkit.session_id()

# 把销售、查询和兑奖接口中的公共部分抽取出来,定义成一个字典,避免代码重复
general_out_content = {
    "PartnerId": basic_data.partner_id,
    "TimeStamp": Toolkit.time_stamp_gen(),
    "SerialNum": basic_data.serial_num_gen(),
    "Version": basic_data.version,
    "Token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "ReqContent": ""
}


@pytest.fixture()
def per_sell_case(request):
    """
    每条销售测试用例的数据处理fixture:完成数据的组装、请求的发送和响应数据的返回
    :param request: 代表每条销售测试用例
    :return:
    """

    # 销售测试用例请求数据的组装:因常规玩法和特殊玩法测试数据来源于不同的表,所以需要分别处理