Commit 3c55473b by taoke

电子证照增加 绑定车辆,解绑车辆用例

parent 48ee89f2
...@@ -10,6 +10,29 @@ from service.login import BMY ...@@ -10,6 +10,29 @@ from service.login import BMY
from common.tools import request_main from common.tools import request_main
from config import BaseConfig,BMCConfig from config import BaseConfig,BMCConfig
from service.login import BMC from service.login import BMC
from common.db import RedisString
"""环境初始化和清除"""
# 1.headers获取
headers = BMCConfig.headers
headers['Pvt-Token'] = BMCConfig.bmc_pvt_token
headers['Token'] = BMCConfig.bmc_token
@pytest.fixture(scope='function') # 绑定车辆 初始化
def get_code() : # 绑定车辆时获取验证码(手机号是绑定车辆固定参数的手机号)
payload = {"plateType": "02", "plateNum": "贵APS001", "vehicleIdentifyNum": "000001", "ownerName": "配送车"}
requests.get(f"{BMCConfig().host}/vehicle/vCode/detail", params=payload, headers=headers)
num = RedisString(0).get(f"edl:sms_value:18581438351:BIND_VEHICLE")
num = str(num)[-7:-1]
return num
@pytest.fixture(scope='function') # 解绑车辆初始化
def get_vehickleId_Tounbind():
res= requests.get(f"{BMCConfig().pvthost}/vehicle/license/list", headers=headers)
for dic in res.json()['data']['list']:
if dic['plateNumName'] == '贵A·PS001': # 为绑定车辆的车牌
vehicleId = dic['vehicleId']
return vehicleId
...@@ -17,8 +40,6 @@ from service.login import BMC ...@@ -17,8 +40,6 @@ from service.login import BMC
@allure.feature("电子驾驶证") @allure.feature("电子驾驶证")
class TestDrivingLicense(): class TestDrivingLicense():
workBook = xlrd.open_workbook(f'{BaseConfig.root_path}/test_case_data/bmc/bmc_testcase01_20210513.xlsx') workBook = xlrd.open_workbook(f'{BaseConfig.root_path}/test_case_data/bmc/bmc_testcase01_20210513.xlsx')
@allure.story("二维码详情") @allure.story("二维码详情")
@allure.link("http://yapi.hikcreate.com/project/32/interface/api/81596") @allure.link("http://yapi.hikcreate.com/project/32/interface/api/81596")
@allure.description("/dlVeh/qr") @allure.description("/dlVeh/qr")
...@@ -127,18 +148,14 @@ class TestDrivingLicense(): ...@@ -127,18 +148,14 @@ class TestDrivingLicense():
req_data = inData['reqData'] req_data = inData['reqData']
# expectData = inData['expectData'] # expectData = inData['expectData']
# headers = inData['headers'] # headers = inData['headers']
headers = BMCConfig.headers
headers['Pvt-Token'] = BMCConfig.bmc_pvt_token
headers['Token'] = BMCConfig.bmc_token
"""请求""" """请求"""
res = requests.get(url,params=req_data,headers=headers) res = requests.get(url,params=req_data,headers=headers)
"""断言,此接口响应和其他不通,暂未做断言""" """断言,此接口响应和其他不通,暂未做断言"""
# assert res['code'] == expectData['code'] # assert res['code'] == expectData['code']
# @pytest.fixture(scope='function') # 用例中不能这么写
# @pytest.mark.usefixtures('test_vehicleLicenseList')
@allure.story("我的行驶证列表") @allure.story("我的行驶证列表")
@allure.link("http://yapi.hikcreate.com/project/32/interface/api/46536") @allure.link("http://yapi.hikcreate.com/project/32/interface/api/46536")
@allure.description("/vehicle/license/list") @allure.description("/vehicle/license/list")
...@@ -154,7 +171,10 @@ class TestDrivingLicense(): ...@@ -154,7 +171,10 @@ class TestDrivingLicense():
res = request_main(url, headers, method, req_data) res = request_main(url, headers, method, req_data)
"""断言""" """断言"""
assert res['code'] == expectData['code'] assert res['code'] == expectData['code']
return res['data']['list'][0]['vehicleId']
@pytest.mark.run(order=664) # 建议放在 绑定用例之后
@allure.story("行驶证二维码") @allure.story("行驶证二维码")
@allure.link("http://yapi.hikcreate.com/project/32/interface/api/81596") @allure.link("http://yapi.hikcreate.com/project/32/interface/api/81596")
@allure.description("/dlVeh/qr(电子行驶证二维码)") @allure.description("/dlVeh/qr(电子行驶证二维码)")
...@@ -165,15 +185,12 @@ class TestDrivingLicense(): ...@@ -165,15 +185,12 @@ class TestDrivingLicense():
method = inData['method'] method = inData['method']
req_data = inData['reqData'] req_data = inData['reqData']
expectData = inData['expectData'] expectData = inData['expectData']
headers = inData['headers']
"""处理""" """处理"""
# 1.使用行驶证列表接口获取一个车的vehicleId # 1.使用行驶证列表接口获取一个车的vehicleId
headers = BMCConfig.headers
headers['Pvt-Token'] = BMCConfig.bmc_pvt_token
headers['Token'] = BMCConfig.bmc_token
resp = requests.get(f"{BMCConfig().pvthost}/vehicle/license/list", headers=headers) resp = requests.get(f"{BMCConfig().pvthost}/vehicle/license/list", headers=headers)
vehicleId = resp.json()['data']['list'][0]['vehicleId'] vehicleId = resp.json()['data']['list'][0]['vehicleId']
# 2.修改参数 # 2.修改参数
req_data['vehicleId'] = vehicleId req_data['vehicleId'] = vehicleId
...@@ -182,7 +199,32 @@ class TestDrivingLicense(): ...@@ -182,7 +199,32 @@ class TestDrivingLicense():
"""断言""" """断言"""
assert res['code'] == expectData['code'] assert res['code'] == expectData['code']
@pytest.mark.scoreDetail """把其他某个用例做为初始化,这种方式还需讨论,暂时不行"""
# # @pytest.mark.scoreDetail
# @allure.story("行驶证二维码2")
# @allure.link("http://yapi.hikcreate.com/project/32/interface/api/81596")
# @allure.description("/dlVeh/qr(电子行驶证二维码)")
# @allure.title("{inData[testPoint]}")
# @pytest.mark.parametrize("inData", get_excelData(workBook, '电子证照', 'vehicledlVehqr'))
# def test_vehicledlVehqr2(self, inData,test_vehicleLicenseList):
# url = f"{BMCConfig().pvthost}{inData['url']}"
# method = inData['method']
# req_data = inData['reqData']
# expectData = inData['expectData']
# headers = inData['headers']
#
# """处理"""
# # 2.修改参数
# print("我打印一下", req_data)
# req_data['vehicleId'] = test_vehicleLicenseList
# print("我打印一下",req_data)
#
# """请求"""
# res = request_main(url, headers, method, req_data)
# """断言"""
# assert res['code'] == expectData['code']
@allure.story("车辆管理列表") @allure.story("车辆管理列表")
@allure.link("http://yapi.hikcreate.com/project/32/interface/api/10913") @allure.link("http://yapi.hikcreate.com/project/32/interface/api/10913")
@allure.description("/vehicle/manage/list") @allure.description("/vehicle/manage/list")
...@@ -199,15 +241,80 @@ class TestDrivingLicense(): ...@@ -199,15 +241,80 @@ class TestDrivingLicense():
"""断言""" """断言"""
assert res['code'] == expectData['code'] assert res['code'] == expectData['code']
@pytest.mark.run(order=662)
@allure.story("绑定机动车-发送验证码")
@allure.link("http://yapi.hikcreate.com/project/31/interface/api/8261")
@allure.description("/vehicle/vCode/detail")
@allure.title("{inData[testPoint]}")
@pytest.mark.parametrize("inData", get_excelData(workBook, '电子证照', 'bindVcode'))
def test_bindVcode(self, inData):
url = f"{BMCConfig().host}{inData['url']}"
method = inData['method']
req_data = inData['reqData']
expectData = inData['expectData']
headers = inData['headers']
"""请求"""
res = request_main(url, headers, method, req_data)
"""断言"""
assert res['code'] == expectData['code']
@pytest.mark.run(order=663)
@allure.story("绑定机动车-提交")
@allure.link("http://yapi.hikcreate.com/project/31/interface/api/8268")
@allure.description("/vehicle/bind")
@allure.title("{inData[testPoint]}")
@pytest.mark.parametrize("inData", get_excelData(workBook, '电子证照', 'vehicleBind'))
def test_vehicleBind(self, inData,get_code):
url = f"{BMCConfig().host}{inData['url']}"
method = inData['method']
req_data = inData['reqData']
expectData = inData['expectData']
headers = inData['headers']
"""处理"""
# 若参数读出为验证码88888,则修改为正确的
if req_data["verifyCode"]=="888888":
req_data["verifyCode"]= get_code
else:
pass
"""请求"""
res = request_main(url, headers, method, req_data)
"""断言"""
assert res['code'] == expectData['code']
@pytest.mark.run(order=665) # 需要在绑定用例之后
@allure.story("解绑机动车备案")
@allure.link("http://yapi.hikcreate.com/project/32/interface/api/1888")
@allure.description("/vehicle/unbind")
@allure.title("{inData[testPoint]}")
@pytest.mark.parametrize("inData", get_excelData(workBook, '电子证照', 'vehicleUnbind'))
def test_vehicleUnbind(self, inData, get_vehickleId_Tounbind):
url = f"{BMCConfig().pvthost}{inData['url']}"
method = inData['method']
req_data = inData['reqData']
expectData = inData['expectData']
headers = inData['headers']
"""处理"""
req_data["vehicleId"] = get_vehickleId_Tounbind
"""请求"""
res = request_main(url, headers, method, req_data)
"""断言"""
assert res['code'] == expectData['code']
def teardown_class(self): def teardown_class(self):
"""清除""" """清除"""
if __name__ == '__main__': if __name__ == '__main__':
for one in os.listdir('../../report/tmp'): # 列出对应文件夹的数据 '-m','scoreDetail' , for one in os.listdir('../../report/tmp'): # 列出对应文件夹的数据 '-m','scoreDetail' ,
if 'json' in one: if 'json' in one:
os.remove(f'../../report/tmp/{one}') os.remove(f'../../report/tmp/{one}')
pytest.main(['test_ ElectronicLicense.py', '-s', '-m','scoreDetail' , '--alluredir','../../report/tmp']) pytest.main(['test_ ElectronicLicense.py', '-s', '--alluredir','../../report/tmp'])
# 启动默认浏览器打开报告 # 启动默认浏览器打开报告
os.system('allure serve ../../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