Commit ee17de83 by taoke

1.修改读取xecle的方法

2.完成企业云登录接口的测试用例
parent 07f344f5
......@@ -15,12 +15,13 @@ def get_excelData(workBook,sheetName,caseName):
num_reqData = list_title.index('reqData')
num_expectData = list_title.index('expectData')
lis = []
dict0 = {"url": "", "headers": "", "method": "", "reqData": "", "expectData": ""}
idx = 0
try:
for one in workSheet.col_values(0):
result = ''.join(re.findall(r'[A-Za-z]', one)) # 抽取字母字符串
if caseName == result:
dict0 = {"url": "", "headers": "", "method": "", "reqData": "", "expectData": ""}
dict0['url'] = workSheet.cell_value(idx, num_url)
dict0['headers'] = workSheet.cell_value(idx, num_headers)
dict0['method'] = workSheet.cell_value(idx, num_method)
......@@ -34,7 +35,6 @@ def get_excelData(workBook,sheetName,caseName):
dict0['headers'] = json.loads(dict0['headers'])
except:
print('header无')
lis.append(dict0)
idx += 1
return lis
......@@ -44,7 +44,7 @@ def get_excelData(workBook,sheetName,caseName):
print("检查excle中标题是否正确")
if __name__ == '__main__':
workBook = xlrd.open_workbook('../../test_case_data/bmy_case.xlsx')
workBook = xlrd.open_workbook('../../test_case_data/bmy/bmy_case.xlsx')
li = get_excelData(workBook,"登录模块","Login")
print(li)
......
......@@ -7,6 +7,7 @@ from common.utils.encryption import Encryption
from common.tools import request_main
from common.db import RedisString
@pytest.fixture(scope='session')
def sso_login(url, headers, method, data):
"""SSO登录"""
......
# 作者: taoke
# 时间: 2021/5/6 21:10
# 编码: #coding:utf-8
# 版本: python3.7
\ No newline at end of file
# 作者: taoke
# 时间: 2021/5/6 21:10
# 编码: #coding:utf-8
# 版本: python3.7
import pytest,allure,xlrd,requests,os
from common.utils.getExcelData import get_excelData
from service.login import BMY
from common.tools import request_main
@allure.epic("营运车企业端")
@allure.feature("登录模块")
class TestLogin():
workBook = xlrd.open_workbook('../../test_case_data/bmy/bmy_case.xlsx')
@allure.story("登录")
@allure.title("登录认证")
@allure.testcase("http://yapi.hikcreate.com/")
@allure.description("url:/auth/login 。。。。")
@pytest.mark.parametrize("inData", get_excelData(workBook,'登录模块', 'Login'))
def test_login(self,inData):
url = inData['url']
method = inData['method']
req_data = inData['reqData']
expectData= inData['expectData']
headers = inData['headers']
"""处理"""
authorization = BMY().get_authorization() #
headers["Authorization"]=authorization
# 密码加密
password_Encrypted = BMY().pwd_encrypted(req_data['password'])
req_data['password'] = password_Encrypted
# 获取图片信息
imageinfo = BMY().get_imageCode(req_data['username'], req_data['password'])
req_data['imageId'] = imageinfo[0]
req_data['imageCode'] = imageinfo[1]
req_data['grant_type']= "passwordImageCode"
"""请求"""
# res = request_main(f"http://testyun.banmago.com/api{url}", headers, method, req_data)
res = requests.post(f"http://testyun.banmago.com/api{url}", data=req_data, headers=headers)
# print(res.json())
"""断言"""
assert res.json()['code'] == expectData['code']
if __name__ == '__main__':
for one in os.listdir('../../report/tmp'): # 列出对应文件夹的数据
if 'json' in one:
os.remove(f'../../report/tmp/{one}')
pytest.main(['test_login.py', '-s', '--alluredir', '../../report/tmp'])
# # 启动默认浏览器打开报告
os.system('allure serve ../../report/tmp')
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