diff --git a/InsertData.robot b/InsertData.robot index 665e01b..c9f3852 100644 --- a/InsertData.robot +++ b/InsertData.robot @@ -5,7 +5,7 @@ Library DatabaseLibrary *** Test Cases *** ReadData - Import Variables D:\\LYL\\Study\\Ptest\\用户资料\\Execl.py + Import Variables ${CURDIR}\\用户资料\\Execl.py #${DList} Set Variable ${cap} log ${phone_list} LOG ${phone} @@ -20,26 +20,3 @@ Connect_Database ${UserData} Query SELECT * FROM `uec`.`qn_account` WHERE `tid` = '13517986787' AND `is_delete` = '0' ${accountId} Set Variable ${UserData[0][0]} Disconnect From Database - -ReadData-1 - #读取execl表数据 - Open Excel D:\\LYL\\Study\\Robot_framework\\space\\Dating-Agency\\相亲用户资料.xls - ${rowCount} Get Row Count 用户资料 #获取表行数 - ${List} Create List - FOR ${x} IN RANGE ${rowCount -1} #读取count-1行,不读取首行 - ${read_row} Get Row Values 用户资料 ${x+1} #1代表execl的第一行,读完${rowCount}是一个list - Set Suite Variable ${read_row} - #\ Insert_Into_List ${List} ${x} ${row_list} - #${Count_List} Evaluate len(${List}) - #Set Suite Variable ${Count_List} - #Set Suite Variable ${List} - -*** Keywords *** -Keyword - #处理每行的List - ${row_list} Create List - ${count_column} Get Column Count 用户资料 #获取表列数 - @{int_values_index} Create List ${1} ${2} ${3} ${4} ${5} ${7} ${9} ${10} ${11} ${12} - FOR ${i} IN RANGE ${count_column} #循环文本列数 - ${row_values} Set Variable ${read_row[${i}][1]} - ${if_empty} Run Keyword And Return Status Should Be Equal As Strings ${row_values} ${empty} #判断是否为空 diff --git a/Opr-Center-RF-Api/000Login/LoginCase.robot b/Opr-Center-RF-Api/000Login/LoginCase.robot index 18705b2..65001a6 100644 --- a/Opr-Center-RF-Api/000Login/LoginCase.robot +++ b/Opr-Center-RF-Api/000Login/LoginCase.robot @@ -1,5 +1,5 @@ *** Settings *** -Suite Setup Import Variables D:\\LYL\\Study\\Robot_framework\\space\\Opr-Center-RF-Api\\000Login\\login.yaml +Suite Setup Import Variables ${CURDIR}\\login.yaml Resource LoginResource.robot *** Test Cases *** diff --git a/用户资料/DataBase.py b/用户资料/DataBase.py new file mode 100644 index 0000000..10218d1 --- /dev/null +++ b/用户资料/DataBase.py @@ -0,0 +1,18 @@ +import pymysql +import xlrd + +""" +一、连接mysql数据库 +""" +# 打开数据库连接 +conn = pymysql.connect( + host='8.135.8.221', # MySQL服务器地址 + user='root', # 用户名 + password='qniaothreetwoonego', # 密码 + charset='utf8', + port=3306, # 端口 + database='dating-agency-service', # 数据库名称 +) + +#断开连接 +conn.close() \ No newline at end of file diff --git a/用户资料/Execl.py b/用户资料/Execl.py new file mode 100644 index 0000000..72f5b62 --- /dev/null +++ b/用户资料/Execl.py @@ -0,0 +1,53 @@ +import xlrd + +# """ +# 二、读取excel文件 +# """ +# FilePath = 'D:/LYL/Study/Robot_framework/space/Dating-Agency/相亲用户资料.xls' +# +# # 1.打开excel文件 +# wkb = xlrd.open_workbook(FilePath) +# # 2.获取sheet +# sheet = wkb.sheet_by_index(0) # 获取第一个sheet表['用户资料'] +# # 3.获取总行数 +# rows_number = sheet.nrows +# # 4.遍历sheet表中所有行的数据,并保存至一个空列表cap[] +# cap = [] +# for i in range(1,rows_number): # 跳过表头 +# x = sheet.row_values(i) # 获取第i行的值(从0开始算起) +# cap.append(x) +# print(cap) +# +# +# for Userinfo in cap: +# # U = int(Userinfo[0]) +# Uname = Userinfo[0] +# Usex = Userinfo[1] +# Uhight = int(Userinfo[2]) +# Uwight = int(Userinfo[3]) +# Uage = int(Userinfo[4]) +# Ucity = Userinfo[5] +# Uedu = Userinfo[6] +# Umarry = Userinfo[7] +# Uincome = Userinfo[8] +# Unickname = Userinfo[9] +# + +""" + 读取phone-text.txt文件的第一列数据 +""" +phone_list = [] +try: + file = open('D:/LYL/Test/ZTB/phone - test.txt', 'r') +except FileNotFoundError: + print('File is not found') +else: + lines = file.readlines() + for line in lines: + a = line.split(',') + x = a[0] + phone_list.append(x) +file.close() + +for Phone in phone_list: + print(Phone) \ No newline at end of file diff --git a/用户资料/WXlogin.py b/用户资料/WXlogin.py new file mode 100644 index 0000000..0465686 --- /dev/null +++ b/用户资料/WXlogin.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +# import weixin +from datetime import datetime, timedelta +from flask import Flask, redirect, request, url_for +from weixin import WeixinLogin + + + +app = Flask(__name__) + +app_id = 'wx13d6b82e0cf2bd9b' +app_secret = '' +wx_login = WeixinLogin(app_id, app_secret) + + +@app.route("/login") +def login(): + openid = request.cookies.get("openid") + next = request.args.get("next") or request.referrer or "/", + if openid: + return redirect(next) + + callback = url_for("authorized", next=next, _external=True) + url = wx_login.authorize(callback, "snsapi_base") + return redirect(url) + + +@app.route("/authorized") +def authorized(): + code = request.args.get("code") + if not code: + return "ERR_INVALID_CODE", 400 + next = request.args.get("next", "/") + data = wx_login.access_token(code) + openid = data.openid + resp = redirect(next) + expires = datetime.now() + timedelta(days=1) + resp.set_cookie("openid", openid, expires=expires) + return resp \ No newline at end of file diff --git a/用户资料/__pycache__/Execl.cpython-36.pyc b/用户资料/__pycache__/Execl.cpython-36.pyc new file mode 100644 index 0000000..036e077 Binary files /dev/null and b/用户资料/__pycache__/Execl.cpython-36.pyc differ diff --git a/用户资料/input.py b/用户资料/input.py new file mode 100644 index 0000000..6a86b65 --- /dev/null +++ b/用户资料/input.py @@ -0,0 +1,89 @@ +import pymysql +import xlrd + +""" +一、连接mysql数据库 +""" +# 打开数据库连接 +conn = pymysql.connect( + host='8.135.8.221', # MySQL服务器地址 + user='root', # 用户名 + password='qniaothreetwoonego', # 密码 + charset='utf8', # + port=3308, # 端口 + db='dating-agency-service', # 数据库名称 +) + +# 使用cursor()方法获取操作游标 +c = conn.cursor() + + +# """ +# 二、读取excel文件 +# """ +# FilePath = 'D:/LYL/Study/Robot_framework/space/Dating-Agency/相亲用户资料.xls' +# +# # 1.打开excel文件 +# wkb = xlrd.open_workbook(FilePath) +# # 2.获取sheet +# sheet = wkb.sheet_by_index(0) # 获取第一个sheet表['用户资料'] +# # 3.获取总行数 +# rows_number = sheet.nrows +# # 4.遍历sheet表中所有行的数据,并保存至一个空列表cap[] +# cap = [] +# for i in range(1,rows_number): +# x = sheet.row_values(i) # 获取第i行的值(从0开始算起) +# cap.append(x-1) +# print(cap) + +# """ +# 三、将读取到的数据批量插入数据库 +# """ +# for Userinfo in cap: +# # U = int(Userinfo[0]) +# Uname = Userinfo[0] +# Usex = Userinfo[1] +# Uhight = int(Userinfo[2]) +# Uwight = int(Userinfo[3]) +# Uage = int(Userinfo[4]) +# Ucity = Userinfo[5] +# Uedu = Userinfo[6] +# Umarry = Userinfo[7] +# Uincome = Userinfo[8] +# Unickname = Userinfo[9] +# # 使用f-string格式化字符串,对sql进行赋值 +# c.execute(f"insert into student(Sno,Sname,Ssex,Sage,Sdept) value ('{Uname}','{Usex}','{Uhight}','{Uage}','{Ucity}','{Uedu}','{Umarry}','{Uincome}','{Unickname}')") +# conn.commit() +# conn.close() +# print("插入数据完成!") + + +""" + 读取phone-text.txt文件的第一列数据 +""" +phone_list = [] +try: + file = open('D:/LYL/Test/ZTB/phone - test.txt', 'r') +except FileNotFoundError: + print('File is not found') +else: + lines = file.readlines() + for line in lines: + a = line.split(',') + x = a[0] + phone_list.append(x) +file.close() +# +for Phone in phone_list: + print(Phone) + + + +""" +三、查询数据库account表中tid=Phone的所有数据 +""" +for Phone in phone_list: + print(Phone) + c.execute(f"SELECT * FROM `uec`.`qn_account` WHERE `tid` = '{Phone}' AND `is_delete` = '0'") +conn.commit() +conn.close() \ No newline at end of file diff --git a/用户资料/phone.py b/用户资料/phone.py new file mode 100644 index 0000000..0be5fef --- /dev/null +++ b/用户资料/phone.py @@ -0,0 +1,27 @@ +import random + +# def create_a_phone(): +# # 第二位数字 +# second = [3, 4, 5, 7, 8][random.randint(0, 4)] +# # 第三位数字 +# third = {3: random.randint(0, 9), +# 4: [5, 7, 9][random.randint(0, 2)], +# 5: [i for i in range(10) if i != 4][random.randint(0, 8)], +# 7: [i for i in range(10) if i not in [4, 9]][random.randint(0, 7)], +# 8: random.randint(0, 9), }[second] +# # **后八位数字 +# suffix = random.randint(9999999, 100000000) +# # 拼接手机号 +# return "1{}{}{}".format(second, third, suffix) +# +# create_a_phone() + + + +def raddomPhone(): + headList = ["130", "131", "132", "133", "134", "135", "136", "137", "138", "139", + "147", "150", "151", "152", "153", "155", "156", "157", "158", "159", + "186", "187", "188", "189"] + return (random.choice(headList) + "".join(random.choice("0123456789") for i in range(8))) + +