Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InterfaceAutoTest
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TestAuto
InterfaceAutoTest
Commits
3c55473b
Commit
3c55473b
authored
May 17, 2021
by
taoke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
电子证照增加 绑定车辆,解绑车辆用例
parent
48ee89f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
121 additions
and
14 deletions
+121
-14
test_case/bmc/test_ ElectronicLicense.py
+121
-14
test_case_data/bmc/bmc_testcase01_20210513.xlsx
+0
-0
No files found.
test_case/bmc/test_ ElectronicLicense.py
View file @
3c55473b
...
...
@@ -10,6 +10,29 @@ from service.login import BMY
from
common.tools
import
request_main
from
config
import
BaseConfig
,
BMCConfig
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
@allure.feature
(
"电子驾驶证"
)
class
TestDrivingLicense
():
workBook
=
xlrd
.
open_workbook
(
f
'{BaseConfig.root_path}/test_case_data/bmc/bmc_testcase01_20210513.xlsx'
)
@allure.story
(
"二维码详情"
)
@allure.link
(
"http://yapi.hikcreate.com/project/32/interface/api/81596"
)
@allure.description
(
"/dlVeh/qr"
)
...
...
@@ -127,18 +148,14 @@ class TestDrivingLicense():
req_data
=
inData
[
'reqData'
]
# expectData = inData['expectData']
# 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
)
"""断言,此接口响应和其他不通,暂未做断言"""
# assert res['code'] == expectData['code']
# @pytest.fixture(scope='function') # 用例中不能这么写
# @pytest.mark.usefixtures('test_vehicleLicenseList')
@allure.story
(
"我的行驶证列表"
)
@allure.link
(
"http://yapi.hikcreate.com/project/32/interface/api/46536"
)
@allure.description
(
"/vehicle/license/list"
)
...
...
@@ -154,7 +171,10 @@ class TestDrivingLicense():
res
=
request_main
(
url
,
headers
,
method
,
req_data
)
"""断言"""
assert
res
[
'code'
]
==
expectData
[
'code'
]
return
res
[
'data'
][
'list'
][
0
][
'vehicleId'
]
@pytest.mark.run
(
order
=
664
)
# 建议放在 绑定用例之后
@allure.story
(
"行驶证二维码"
)
@allure.link
(
"http://yapi.hikcreate.com/project/32/interface/api/81596"
)
@allure.description
(
"/dlVeh/qr(电子行驶证二维码)"
)
...
...
@@ -165,15 +185,12 @@ class TestDrivingLicense():
method
=
inData
[
'method'
]
req_data
=
inData
[
'reqData'
]
expectData
=
inData
[
'expectData'
]
headers
=
inData
[
'headers'
]
"""处理"""
# 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
)
vehicleId
=
resp
.
json
()[
'data'
][
'list'
][
0
][
'vehicleId'
]
# 2.修改参数
req_data
[
'vehicleId'
]
=
vehicleId
...
...
@@ -182,7 +199,32 @@ class TestDrivingLicense():
"""断言"""
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.link
(
"http://yapi.hikcreate.com/project/32/interface/api/10913"
)
@allure.description
(
"/vehicle/manage/list"
)
...
...
@@ -199,15 +241,80 @@ class TestDrivingLicense():
"""断言"""
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
):
"""清除"""
if
__name__
==
'__main__'
:
for
one
in
os
.
listdir
(
'../../report/tmp'
):
# 列出对应文件夹的数据 '-m','scoreDetail' ,
if
'json'
in
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'
)
test_case_data/bmc/bmc_testcase01_20210513.xlsx
View file @
3c55473b
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment