Commit b9ec102c by linguangwei

review

parent 6b16d1fa
...@@ -14,6 +14,7 @@ env = prod ...@@ -14,6 +14,7 @@ env = prod
[header_require] [header_require]
lgw-b = {"username":"13777867342", "password":"0000", "userId":"1394908740376522754","storeId":"1211601438838495999","storeUserId":"1394257952460828673","enterpriseId":"1398199018246803458"} lgw-b = {"username":"13777867342", "password":"0000", "userId":"1394908740376522754","storeId":"1211601438838495999","storeUserId":"1394257952460828673","enterpriseId":"1398199018246803458"}
lgw-c = {"userId":"1398199018305576961","storeId":"1211601438838495999","enterpriseId":"1398199018246803458","storeCustomerId":"1417771709685088257"}
zhangy-b = {"username":"15068165765", "password":"0000", "userId":"1351044240032444418","storeId":"1211601438838495999","storeUserId":"1416964747960832001","enterpriseId":"1398199018246803458"} zhangy-b = {"username":"15068165765", "password":"0000", "userId":"1351044240032444418","storeId":"1211601438838495999","storeUserId":"1416964747960832001","enterpriseId":"1398199018246803458"}
[MySql] [MySql]
......
...@@ -7,7 +7,7 @@ from src.framework import common ...@@ -7,7 +7,7 @@ from src.framework import common
if __name__ == '__main__': if __name__ == '__main__':
htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute()) htmlPath = "./report/AI-XM_Report{}.html".format(common.year_to_minute())
pytest.main(["-v", '--alluredir={}'.format(htmlPath), './src/testcase/', "--durations=0"]) pytest.main(["-v", '--reruns', '2', '--reruns-delay', '60', '--alluredir={}'.format(htmlPath), './src/testcase/', "--durations=0"])
os.system('allure generate {} -o ./report/output --clean'.format(htmlPath)) os.system('allure generate {} -o ./report/output --clean'.format(htmlPath))
# os.system('allure open report/output') # os.system('allure open report/output')
time.sleep(5) time.sleep(5)
......
...@@ -83,27 +83,43 @@ def get_allure_screenshots(screenshot_path, describe): ...@@ -83,27 +83,43 @@ def get_allure_screenshots(screenshot_path, describe):
# 小麦接口相关 # 小麦接口相关
# 获取登录token # 获取登录token
def get_token(user): def get_token(user, Terminal):
account = readConfig.test_header(user)['username'] if Terminal == 'SOW-B':
password = readConfig.test_header(user)['password'] account = readConfig.test_header(user)['username']
headers = {"Content-Type": "application/json; charset=UTF-8", password = readConfig.test_header(user)['password']
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " headers = {"Content-Type": "application/json; charset=UTF-8",
"Chrome/91.0.4472.77 Safari/537.36"} "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
params = {"phone": account, "authCode": password, "appTermEnum": "XIAOMAI_CLOUD_CLASS_PC_WEB_ADMIN"} "Chrome/91.0.4472.77 Safari/537.36"}
data = json.dumps(params) params = {"phone": account, "authCode": password, "appTermEnum": "XIAOMAI_CLOUD_CLASS_PC_WEB_ADMIN"}
url = "https://gateway.xiaomai5.com/hades/anon/hades/login?storeId=null&token=null&storeUserId=null&userId=null" data = json.dumps(params)
r = requests.post(url=url, data=data, headers=headers) url = "https://gateway.xiaomai5.com/hades/anon/hades/login?storeId=null&token=null&storeUserId=null&userId=null"
try: r = requests.post(url=url, data=data, headers=headers)
# xmtoken = r.json()["result"]["xmToken"] try:
xmtoken = r.json()["result"] xmtoken = r.json()["result"]
except Exception as e: except Exception as e:
return r.json()["message"] return r.json()["message"]
return xmtoken return xmtoken
elif Terminal == 'SOW-C':
enterpeise_id = readConfig.test_header(user)['enterpriseId']
user_id = readConfig.test_header(user)['userId']
headers = {"Content-Type": "application/json; charset=UTF-8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/91.0.4472.77 Safari/537.36"}
params = {"enterpriseId": enterpeise_id, "userId": user_id, "appTermEnum": "XIAOMAI_CLOUD_CLASS_PC_WEB_ADMIN"}
data = json.dumps(params)
url = "https://gateway.xiaomai5.com/hades/anon/hades/getWXWorkLoginNoCheck"
r = requests.post(url=url, data=data, headers=headers)
try:
# xmtoken = r.json()["result"]["loginInfo"]
xmtoken = r.json()["result"]["loginInfo"]["xmToken"]
except Exception as e:
return r.json()["message"]
return xmtoken
# 创建一个直播课,返回课程id和课程名称 # 创建一个直播课,返回课程id和课程名称
def create_a_live(start_time, start_time2=None, user="lgw-b"): def create_a_live(start_time, start_time2=None, user="lgw-b"):
xmtoken = get_token(user=user)["xmToken"] xmtoken = get_token(user=user, Terminal='SOW-B')["xmToken"]
basic_imforation = readConfig.test_header(header_name=user) basic_imforation = readConfig.test_header(header_name=user)
userId = basic_imforation['userId'] userId = basic_imforation['userId']
storeId = basic_imforation['storeId'] storeId = basic_imforation['storeId']
...@@ -112,7 +128,7 @@ def create_a_live(start_time, start_time2=None, user="lgw-b"): ...@@ -112,7 +128,7 @@ def create_a_live(start_time, start_time2=None, user="lgw-b"):
while xmtoken == "登录过频繁": while xmtoken == "登录过频繁":
# 休息15s是因为可能会登录频繁 # 休息15s是因为可能会登录频繁
time.sleep(15) time.sleep(15)
xmtoken = get_token()["xmToken"] xmtoken = get_token(user=user, Terminal='SOW-B')["xmToken"]
print(xmtoken) print(xmtoken)
dt = year_to_day() + ' 00:00:00' dt = year_to_day() + ' 00:00:00'
calendarTime = int(time.mktime(time.strptime(dt, "%Y-%m-%d %H:%M:%S")))*1000 calendarTime = int(time.mktime(time.strptime(dt, "%Y-%m-%d %H:%M:%S")))*1000
...@@ -162,3 +178,32 @@ def create_a_live(start_time, start_time2=None, user="lgw-b"): ...@@ -162,3 +178,32 @@ def create_a_live(start_time, start_time2=None, user="lgw-b"):
return [courseName] return [courseName]
except Exception as e: except Exception as e:
print(e.args) print(e.args)
def join_live_course(live_id, user='lgw-c'):
xmtoken = get_token(user=user, Terminal='SOW-C')
url = "https://heimdall.xiaomai5.com/hades/public/customerHades/getOrRegisterLiveUser"
basic_imforation = readConfig.test_header(header_name=user)
userId = basic_imforation['userId']
storeId = basic_imforation['storeId']
storeCustomerId = basic_imforation['storeCustomerId']
enterpriseId = basic_imforation['enterpriseId']
params = {"courseId": live_id, "customerId": storeCustomerId, "storeId": storeId, "userRole": "USER"}
data = json.dumps(params)
headers = {"Content-Type": "application/json; charset=UTF-8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/91.0.4472.77 Safari/537.36",
"storeId": storeId,
"storeCustomerId": storeCustomerId,
"xmtoken": xmtoken,
"userId": userId,
"product": "xmCloudClass",
"enterpriseId": enterpriseId}
r = requests.post(url=url, data=data, headers=headers)
try:
# 校验result中是否会返回课程id
assert r.json()["result"] != ''
return r.json()["result"]
except Exception as e:
print(e.args)
...@@ -11,12 +11,11 @@ ip = socket.gethostbyname(hostname) ...@@ -11,12 +11,11 @@ ip = socket.gethostbyname(hostname)
file_path = file_abspath() + "report\\output\\widgets\\suites.json" file_path = file_abspath() + "report\\output\\widgets\\suites.json"
with open(file_path) as f:
file_context = json.loads(f.read())
result = file_context['items'][0]['statistic']
def alert(): def alert():
with open(file_path) as f:
file_context = json.loads(f.read())
result = file_context['items'][0]['statistic']
# 获取当前日期 # 获取当前日期
tile = time.strftime("%Y-%m-%d %H:%M:%S") tile = time.strftime("%Y-%m-%d %H:%M:%S")
url = "https://oapi.dingtalk.com/robot/send" url = "https://oapi.dingtalk.com/robot/send"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment