Exemple #1
0
class CreateIdAndRealName():
    def __init__(self):
        self.generater = []
        self.randomCode = ""
        self.result = 0
        self.readConfig = ReadConfig()

    def createIdNum(self):
        #生成地区号
        index = int(random.random()*len(areaCode))
        values = list(areaCode.values())
        self.generater.append(values[index])
        #生日
        birth_year = int((random.random() * 20) + 1980)
        birth_month = int(random.random() * 12 + 1)
        birth_day = int((random.random() * 31))
        builder = []
        builder.append(str(birth_year))
        if birth_month < 10:
            builder.append("0")
        builder.append(str(birth_month))
        if birth_day < 10:
            builder.append("0")
        builder.append(str(birth_day))
        builder = ''.join(str(i) for i in builder)
        self.generater.append(builder)
        #随机码
        code1 = int(random.random()*1000)
        if code1 < 10:
            self.randomCode = "00" + str(code1)
        elif code1 < 100:
            self.randomCode = "0" + str(code1)
        else:
            self.randomCode = str(code1)
        self.generater.append(self.randomCode)
        temp = "".join(str(i) for i in self.generater)
        #验证码
        c = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
        r = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
        #将generater 的前17为进行字节化

        for k in range(17):
            self.result += c[k] * int(temp[k])
        validateCode = r[self.result%11]
        self.generater.append(validateCode)
        self.generater = "".join(str(i) for i in self.generater)
        self.readConfig.setResData("IdNum",self.generater)
    def createName(self):
        xingming = []
        index_xing = int(random.random()*len(xing))
        len_xingming = random.choice([1,2])
        xingming.append(xing[index_xing])
        for i in range(len_xingming):
            index_ming = int(random.random() * len(ming))
            xingming.append(ming[index_ming])
        realName = "".join(xingming)
        self.readConfig.setResData("realName",realName)
    def createIdNumAndName(self):
        self.createIdNum()
        self.createName()
Exemple #2
0
def OCRAuth():
    rs = RequestInterface("OCRUrl")
    # 生成姓名和身份证,保存在ResultData
    CreateNameAndIdNum()
    # 获取姓名和身份证
    userName = ReadConfig().getResData("realname")
    IdNum = ReadConfig().getResData("idnum")
    rs.setParams("OCRParams", ["realName", "idNum"], [userName, IdNum])
    jwt = getJwt()
    rs.setHeader("jwt", jwt)
    print(rs.post())
Exemple #3
0
class RequestInterface:
    def __init__(self, option):
        self.readConfig = ReadConfig()
        self.headers = self.readConfig.getInterFaceData("header")
        self.headers = json.loads(self.headers)
        self.url = self.geturl(option)
        self.timeOut = self.readConfig.getInterFaceData("timeout")

    def geturl(self, option):
        return self.readConfig.getInterFaceData(option)

    def setHeader(self, key, value):
        self.headers[key] = value

    #设置接口请求参数
    def setParams(self, option, key: list = None, value: list = None):
        #先获取配置的固定参数
        self.params = self.readConfig.getInterFaceData(option)
        self.params = json.loads(self.params)
        if key and value:
            #设置其中的动态变量
            for k, val in zip(key, value):
                self.params[k] = val

    def getParams(self):
        return self.params

    def get(self):
        try:
            response = requests.get(self.url,
                                    headers=self.headers,
                                    params=self.params,
                                    timeout=float(self.timeOut))
            return response
        except TimeoutError as e:
            print(e)
            return None

    def post(self):
        try:
            respons = requests.post(url=self.url,
                                    headers=self.headers,
                                    json=self.params,
                                    timeout=float(self.timeOut))
            return respons
        except TimeoutError as e:
            print(e)
            return None
Exemple #4
0
def SETHTFen():
    rd = ReadConfig()
    #获取手机号码
    mobile = rd.getResData("mobile")
    #获取 根据手机号码查询userId的sql
    GetUserIdByMobile = rd.getDBData(section="SQL",option="GetUserIdByMobile").format((mobile))
    db_nono = MyDB("dbNonoCofig")
    db_nono.connectDB()
    db_nono.exceuteSQL(GetUserIdByMobile)
    UserId = db_nono.getOne()[0]
    print(UserId)
    db_nono.closeDB()
    db_maiya = MyDB("dbMaiYaCofig")
    SetHTFenSql = rd.getDBData(section="SQL",option="SetHTFen").format(UserId)
    db_maiya.exceuteSQL(SetHTFenSql)
    db_maiya.closeDB()
Exemple #5
0
 def test_03_createOrd(self):
     """  创建订单  """
     #获取手机号
     mobile = ReadConfig().getResData("mobile")
     #调用登录接口,更新存储jwt到配置
     setJwt("login_params", ["loginName", "blackBox"], [mobile, mobile])
     #调用创建订单接口 创建订单
     postCreatOrd()
     #进入首页
     HomePage().firstpage_view.click()
     #刷新获取订单信息
     Driver.d.swipe(0.49, 0.255, 0.501, 0.442)
Exemple #6
0
    def __init__(self):
        global host, user, password, port, sender, title, content

        host = ReadConfig().getMCData("mailhost")
        user = ReadConfig().getMCData("mailuser")
        port = int(ReadConfig().getMCData("port"))
        sender = ReadConfig().getMCData("sender")
        title = ReadConfig().getMCData("subject")
        password = ReadConfig().getMCData("mailpass")
        content = ReadConfig().getMCData("content")
        self.receiverValue = ReadConfig().getMCData("receiver")
        self.inOff = ReadConfig().getMCData("onoff")
        self.receiverList = []
        #获取收件人列表
        for receiver in str(self.receiverValue).split("/"):
            self.receiverList.append(receiver)
            #定义邮件发送时间
            date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            self.subject = title + ' ' + date
            self.msg = MIMEMultipart("mixed")
Exemple #7
0
 def test_01_sign_up(self, mobile=None):
     """  注册  """
     #点击麦芽首页消费分期
     #Driver.d.xpath('//*[@resource-id="com.maiyafenqi:id/product_rc"]/android.view.View[1]').click()
     #进入我的页面
     HomePage().click_mine_view()
     #点击立即登录
     Driver.d(resourceId="com.maiyafenqi:id/iv_login").click()
     time.sleep(0.5)
     #点击注册按钮 进入注册界面
     Driver.d(resourceId="com.maiyafenqi:id/register_tv").click()
     time.sleep(2)
     if mobile is None:
         mobile = create_iphone_no()
     sign_up_steps(Driver.d, mobile)
     time.sleep(1)
     #保存手机号码
     ReadConfig().setResData(option="mobile", value=mobile)
Exemple #8
0
 def test_02_login(self):
     """  登录  """
     HomePage().click_mine_view()
     #点击立即登录
     Driver.d(resourceId="com.maiyafenqi:id/iv_login").click()
     time.sleep(0.5)
     #输入手机号
     mobile = ReadConfig().getResData("mobile")
     Driver.d(resourceId="com.maiyafenqi:id/phone_et").set_text(
         "{}".format(mobile))
     time.sleep(0.5)
     #输入密码
     Driver.d(
         resourceId="com.maiyafenqi:id/password_et").set_text("it789123")
     time.sleep(0.5)
     # 收起软键盘
     Driver.d.long_click(0.925, 0.517, 1)
     time.sleep(1)
     #点击登录按钮
     Driver.d(resourceId="com.maiyafenqi:id/login_tv").click()
     time.sleep(1)
Exemple #9
0
class MyDB:
    global config,readConfig
    readConfig = ReadConfig()
    # host = readConfig.getDBData("host")
    # port = readConfig.getDBData("port")
    # userName = readConfig.getDBData("username")
    # passWord = readConfig.getDBData("password")
    # database = readConfig.getDBData("database")

    def __init__(self,db_name):
        self.config = json.loads(readConfig.getDBData(section="DATABASE",option=db_name))
        self.db = None
        self.cursor = None
    def connectDB(self):
        try:
            #链接DB
            self.db = pymysql.connect(**self.config)
            #创建游标
            self.cursor = self.db.cursor()
            print("数据库链接成功")
        except ConnectionError as e:
            print(e)
    def exceuteSQL(self,sql):
        self.connectDB()
        #执行sql
        self.cursor.execute(sql)
        #执行完成之后进行提交
        self.db.commit()
        return self.cursor
    def getAll(self):
        value = self.cursor.fetchall()
        return value
    def getOne(self):
        value = self.cursor.fetchone()
        return value
    def closeDB(self):
        try:
            self.db.close()
        except Exception as e:
            print(e)
Exemple #10
0
def getJwt():
    jwt = ReadConfig().getInterFaceData('jwt')
    return jwt
Exemple #11
0
 def __init__(self, option):
     self.readConfig = ReadConfig()
     self.headers = self.readConfig.getInterFaceData("header")
     self.headers = json.loads(self.headers)
     self.url = self.geturl(option)
     self.timeOut = self.readConfig.getInterFaceData("timeout")
Exemple #12
0
 def __init__(self):
     self.generater = []
     self.randomCode = ""
     self.result = 0
     self.readConfig = ReadConfig()