Example #1
0
 def unregister_phone_replace(cls, data):
     """
     正则替换excel中未注册的手机号
     :param data: str包含${unregister_phone}
     :return:
     """
     if re.search(cls.unreg_pattern, data):
         do_mysql = MysqlHandler()
         phone = do_mysql.create_unregist_phone()
         data = re.sub(cls.unreg_pattern, phone,
                       data)  # 替换成数据库没有记录的随机手机号,sub()第二个第三个参数必须是字符串
         do_mysql.close()  # 关闭数据库连接
     return data
Example #2
0
 def null_loan_id_replace(cls, data):
     """
     正则替换excel中不存在的标id
     :param data: str包含${null_load_id}
     :return:
     """
     if re.search(cls.null_loan_id_pattern, data):
         do_mysql = MysqlHandler()
         sql = "SELECT `Id` FROM future.`loan`ORDER BY `CreateTime` DESC LIMIT 1;"
         unexist_id = do_mysql(
             sql=sql).get('Id') + 100  # 获取最大id+100,即不存在的标id
         data = re.sub(cls.null_loan_id_pattern, str(unexist_id),
                       data)  # 替换成数据库没有记录的标id,sub()第二个第三个参数必须是字符串
         do_mysql.close()  # 关闭数据库连接
     return data
Example #3
0
 def loan_id_replace(cls, data):
     """
     正则替换excel中已有的标id
     :param data: str包含${load_id}
     :return:
     """
     if re.search(cls.loan_id_pattern, data):
         do_mysql = MysqlHandler()
         sql = "SELECT `Id` FROM future.`loan`ORDER BY `CreateTime` DESC LIMIT 1;"
         # getattr()第一个参数为对象(类),第二个参数为字符串类型的属性名
         # setattr(对象,符串类型的属性名, 属性值)
         loan_id = getattr(cls, "loan_id")  # 获取对象(类)的实例属性值(类属性值)
         data = re.sub(cls.loan_id_pattern, str(loan_id),
                       data)  # 替换成数据库没有记录的标id,sub()第二个第三个参数必须是字符串
         do_mysql.close()  # 关闭数据库连接
     return data
Example #4
0
 def setUpClass(cls):
     cls.one_request = HttpRequests()
     user_data = {
         "mobilephone": user_config("invest_user", "phone"),
         "pwd": user_config("invest_user", "pwd")
     }
     cls.one_request('post', cls.base_url + '/member/login', user_data)
     cls.do_mysql = MysqlHandler()
     do_logger.info("\n{:=^50s}".format("开始执行充值接口用例"))
Example #5
0
def create_new_user(regname, pwd="12345678"):
    handle_mysql = MysqlHandler()
    request = HttpRequests()
    sql = "SELECT `Id` FROM future.`member` WHERE `MobilePhone`=%s"
    url = do_config('interface', 'base_url') + "/member/register"
    while True:
        phone = handle_mysql.create_unregist_phone()
        data = {"mobilephone": phone, "pwd": pwd, "regname": regname}
        request('post', url, data)
        result = handle_mysql(sql, (phone, ))
        if result:
            id = result['Id']
            break
    user_dict = {
        regname: {
            'id': id,
            'regname': regname,
            'pwd': pwd,
            'phone': phone
        }
    }
    request.close()
    handle_mysql.close()
    return user_dict
Example #6
0
 def setUpClass(cls):
     cls.one_request = HttpRequests()
     cls.do_mysql = MysqlHandler()
     do_logger.info("\n{:=^50s}".format("开始执行投资接口用例"))