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
9a11bf2b
Commit
9a11bf2b
authored
May 24, 2021
by
huangchengcheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成5月份自动化用例任务
parent
f1cd34dc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
36 deletions
+88
-36
test_case/bmc/test_homebasic.py
+39
-12
test_case/bmc/test_roadreview.py
+49
-24
test_case_data/bmc/bmc_home_basic_functions_2021513.xlsx
+0
-0
test_case_data/bmc/bmc_my_2021513.xlsx
+0
-0
test_case_data/bmc/bmc_road_review_2021513.xlsx
+0
-0
No files found.
test_case/bmc/test_homebasic.py
View file @
9a11bf2b
...
...
@@ -11,11 +11,17 @@ from common.tools import request_main
from
common.utils
import
getExcelData
headers
=
config
.
BMCConfig
.
headers
@allure.feature
(
"首页基础功能"
)
class
TestHomebasic
:
workbook
=
xlrd
.
open_workbook
(
f
'{config.BaseConfig.root_path}/test_case_data/bmc/bmc_home_basic_functions_2021513.xlsx'
)
def
setup_class
(
self
):
config
.
BMCConfig
.
headers
[
"Pvt-Token"
]
=
getattr
(
config
.
BMCConfig
,
"bmc_pvt_token"
)
config
.
BMCConfig
.
headers
[
"Token"
]
=
getattr
(
config
.
BMCConfig
,
"bmc_token"
)
self
.
headers
=
config
.
BMCConfig
.
headers
@allure.story
(
"获取开通城市列表"
)
@allure.link
(
""
)
@allure.description
(
"creator:liaohui,autoCreator:huangchengcheng"
)
...
...
@@ -26,7 +32,7 @@ class TestHomebasic:
method
=
indata
[
"method"
]
data
=
indata
[
"reqData"
]
expectdata
=
indata
[
"expectData"
]
res
=
request_main
(
url
,
headers
,
method
,
data
)
res
=
request_main
(
url
,
self
.
headers
,
method
,
data
)
try
:
assert
res
[
"code"
]
==
expectdata
[
"code"
]
assert
res
[
"success"
]
==
expectdata
[
"success"
]
...
...
@@ -43,7 +49,7 @@ class TestHomebasic:
method
=
indata
[
"method"
]
data
=
indata
[
"reqData"
]
expectdata
=
indata
[
"expectData"
]
res
=
request_main
(
url
=
url
,
data
=
data
,
method
=
method
,
headers
=
headers
)
res
=
request_main
(
url
=
url
,
data
=
data
,
method
=
method
,
headers
=
self
.
headers
)
try
:
assert
res
[
"code"
]
==
expectdata
[
"code"
]
except
Exception
as
e
:
...
...
@@ -55,12 +61,11 @@ class TestHomebasic:
@allure.title
(
"{indata[testPoint]}"
)
@pytest.mark.parametrize
(
"indata"
,
getExcelData
.
get_excelData
(
workbook
,
"首页基础功能"
,
"Newsclassify"
))
def
test_Newsclassify
(
self
,
indata
):
print
(
indata
)
url
=
f
'{config.BMCConfig.host}/{indata["url"]}'
method
=
indata
[
"method"
]
data
=
indata
[
"reqData"
]
expectdata
=
indata
[
"expectData"
]
res
=
request_main
(
url
=
url
,
data
=
data
,
method
=
method
,
headers
=
headers
)
res
=
request_main
(
url
=
url
,
data
=
data
,
method
=
method
,
headers
=
self
.
headers
)
try
:
assert
res
[
"code"
]
==
expectdata
[
"code"
]
except
Exception
as
e
:
...
...
@@ -75,7 +80,7 @@ class TestHomebasic:
method
=
indata
[
"method"
]
expectdata
=
indata
[
"expectData"
]
data
=
indata
[
"reqData"
]
res
=
request_main
(
url
=
url
,
method
=
method
,
data
=
data
,
headers
=
headers
)
res
=
request_main
(
url
=
url
,
method
=
method
,
data
=
data
,
headers
=
self
.
headers
)
try
:
assert
res
[
"code"
]
==
expectdata
[
"code"
]
except
Exception
as
e
:
...
...
@@ -91,28 +96,50 @@ class TestHomebasic:
method
=
indata
[
"method"
]
expectdata
=
indata
[
"expectData"
]
data
=
indata
[
"reqData"
]
res
=
request_main
(
url
=
url
,
method
=
method
,
data
=
data
,
headers
=
headers
)
res
=
request_main
(
url
=
url
,
method
=
method
,
data
=
data
,
headers
=
self
.
headers
)
try
:
assert
res
[
"code"
]
==
expectdata
[
"code"
]
except
Exception
as
e
:
raise
e
@pytest.fixture
(
scope
=
'function'
)
def
newsgetlist
(
self
):
url
=
f
'{config.BMCConfig.host}/news/categoryItems'
method
=
"get"
data
=
{
"categoryId"
:
"1"
,
"page"
:
"1"
,
"size"
:
"20"
}
res
=
request_main
(
url
,
self
.
headers
,
method
,
data
,)
return
res
@allure.story
(
"获得文章详情"
)
@allure.description
(
"creator:liaohui,autoCreator:huangchengcheng"
)
@allure.title
(
"{indata[testPoint]}"
)
@pytest.mark.parametrize
(
"indata"
,
getExcelData
.
get_excelData
(
workbook
,
"首页基础功能"
,
"Newsdetail"
))
def
test_newsdetail
(
self
,
indata
):
def
test_newsdetail
(
self
,
indata
,
newsgetlist
):
url
=
f
'{config.BMCConfig.host}/{indata["url"]}'
method
=
indata
[
"method"
]
expectdata
=
indata
[
"expectData"
]
data
=
indata
[
"reqData"
]
res
=
request_main
(
url
=
url
,
method
=
method
,
data
=
data
,
headers
=
headers
)
try
:
newlist
=
newsgetlist
[
"data"
][
"list"
]
if
newlist
==
[]:
pytest
.
skip
(
"没有文章,无法获取文章详情"
)
else
:
if
len
(
indata
[
"reqData"
][
"id"
])
==
0
:
data
=
indata
[
"reqData"
]
else
:
indata
[
"reqData"
][
"id"
]
=
newlist
[
0
][
"id"
]
data
=
indata
[
"reqData"
]
except
Exception
as
e
:
raise
e
res
=
request_main
(
url
=
url
,
method
=
method
,
data
=
data
,
headers
=
self
.
headers
)
try
:
assert
res
[
"code"
]
==
expectdata
[
"code"
]
except
Exception
as
e
:
raise
e
@allure.story
(
"资讯列表搜索"
)
@allure.description
(
"creator:liaohui,autoCreator:huangchengcheng"
)
@allure.title
(
"{indata[testPoint]}"
)
...
...
@@ -122,7 +149,7 @@ class TestHomebasic:
method
=
indata
[
"method"
]
expectdata
=
indata
[
"expectData"
]
data
=
indata
[
"reqData"
]
res
=
request_main
(
url
=
url
,
method
=
method
,
data
=
data
,
headers
=
headers
)
res
=
request_main
(
url
=
url
,
method
=
method
,
data
=
data
,
headers
=
self
.
headers
)
try
:
assert
res
[
"code"
]
==
expectdata
[
"code"
]
except
Exception
as
e
:
...
...
@@ -133,6 +160,6 @@ class TestHomebasic:
#
# # 生成报告数据
# pytest.main(['-v', '-s', "test_homebasic.py", '--alluredir', './bmc/report',"--clean-alluredir"])
# # pytest.main(['-v', '-s', "test_homebasic.py::TestHomebasic::test_news
getbanner
", '--alluredir', './bmc/report', "--clean-alluredir"])
# # pytest.main(['-v', '-s', "test_homebasic.py::TestHomebasic::test_news
detail
", '--alluredir', './bmc/report', "--clean-alluredir"])
# # 打开报告
# os.system('allure serve ./bmc/report')
test_case/bmc/test_roadreview.py
View file @
9a11bf2b
...
...
@@ -82,7 +82,7 @@ class TestRoadreview:
@allure.description
(
"creator:林静文,autoCreator:huangchengcheng"
)
@allure.title
(
"{indata[testPoint]}"
)
@pytest.mark.parametrize
(
"indata"
,
getExcelData
.
get_excelData
(
workbook
,
"非交通占用道路审查"
,
"roadaddBasicInfo"
))
def
test_
a
roadaddbasicinfo
(
self
,
indata
):
def
test_roadaddbasicinfo
(
self
,
indata
):
url
=
f
'{config.BMCConfig.host}/{indata["url"]}'
data
=
indata
[
"reqData"
]
expectdata
=
indata
[
"expectData"
]
...
...
@@ -94,11 +94,22 @@ class TestRoadreview:
raise
e
@pytest.fixture
(
scope
=
'function'
)
def
roadaddbasicinfo
(
self
):
url
=
f
'{config.BMCConfig.host}/pvtapi/occupy/road/addBasicInfo'
data
=
{
"isHasNotFinish"
:
0
,
"peoplePhone"
:
"18800000044"
,
"companyName"
:
"666"
,
"organizeCode"
:
"168685858588855850"
,
"peopleName"
:
"接口自动化"
,
"id"
:
'null'
}
method
=
'post'
res
=
request_main
(
url
,
self
.
headers
,
method
,
data
)
mysql
=
MYSQL
(
"10.197.236.190"
,
3306
,
"root"
,
"123456"
,
db
=
"db_gy_dmsmp"
)
basic_info_id
=
mysql
.
ExecuQuery
(
"select id from db_gy_dmsmp.occupy_road_apply where user_id=393038 and people_phone='18800000044'order by id;"
)[
-
1
][
"id"
]
return
basic_info_id
@allure.story
(
"业务申请"
)
@allure.description
(
"creator:林静文,autoCreator:huangchengcheng"
)
@allure.title
(
"{indata[testPoint]}"
)
@pytest.mark.parametrize
(
"indata"
,
getExcelData
.
get_excelData
(
workbook
,
"非交通占用道路审查"
,
"roadaddOccupyRoadInfo"
))
def
test_
broadaddoccupyroadinfo
(
self
,
indata
):
def
test_
roadaddoccupyroadinfo
(
self
,
indata
,
roadaddbasicinfo
):
url
=
f
'{config.BMCConfig.host}/{indata["url"]}'
today
=
datetime
.
datetime
.
now
()
offset
=
datetime
.
timedelta
(
days
=
1
)
...
...
@@ -109,11 +120,7 @@ class TestRoadreview:
indata
[
"reqData"
][
"beginDate"
]
=
beginDate
indata
[
"reqData"
][
"endDate"
]
=
endDate
#处理开始结束时间不能小于当前日期问题
mysql
=
MYSQL
(
"10.197.236.190"
,
3306
,
"root"
,
"123456"
,
db
=
"db_gy_dmsmp"
)
basic_info_id
=
mysql
.
ExecuQuery
(
"select id from db_gy_dmsmp.occupy_road_apply where user_id=393038 and people_phone='18800000044'order by id;"
)[
-
1
][
"id"
]
indata
[
"reqData"
][
"id"
]
=
basic_info_id
indata
[
"reqData"
][
"id"
]
=
roadaddbasicinfo
#处理关联任务的请求id
data
=
indata
[
"reqData"
]
res
=
request_main
(
url
,
self
.
headers
,
method
,
data
)
...
...
@@ -123,21 +130,35 @@ class TestRoadreview:
raise
e
"""系统异常"""
# @pytest.mark.skip(reason="不执行该用例,报系统异常")
@pytest.fixture
(
scope
=
"function"
)
def
roadaddoccupyroadinfo
(
self
,
roadaddbasicinfo
):
url
=
f
'{config.BMCConfig.host}//pvtapi/occupy/road/addOccupyRoadInfo'
today
=
datetime
.
datetime
.
now
()
offset
=
datetime
.
timedelta
(
days
=
1
)
beginDate
=
(
today
+
offset
)
.
strftime
(
'
%
Y-
%
m-
%
d'
)
endDate
=
(
today
+
offset
+
offset
)
.
strftime
(
'
%
Y-
%
m-
%
d'
)
reqdata
=
{
"operateType"
:
1
,
"operateReason"
:
2
,
"occupyType"
:
2
,
"beginDate"
:
"2021-05-10"
,
"endDate"
:
"2021-07-10"
,
"roadRemark"
:
"这是接口自动化数据"
,
"width"
:
"2"
,
"length"
:
"10"
,
"vehicle"
:[{
"plateType"
:
"蓝牌"
,
"plateNum"
:
"京A 54344"
}],
"time"
:
[{
"beginTime"
:
"06:00"
,
"endTime"
:
"18:00"
}],
"roadName"
:
"四川省成都市双流区湖畔路北段"
,
"roadLng"
:
104.090169
,
"roadLat"
:
30.402453
,
"id"
:
"404"
}
method
=
'post'
reqdata
[
"beginDate"
]
=
beginDate
reqdata
[
"endDate"
]
=
endDate
# 处理开始结束时间不能小于当前日期问题
reqdata
[
"id"
]
=
roadaddbasicinfo
# 处理关联任务的请求id
data
=
reqdata
res
=
request_main
(
url
,
self
.
headers
,
method
,
data
)
@pytest.mark.usefixtures
(
"roadaddoccupyroadinfo"
)
@allure.story
(
"业务申请"
)
@allure.description
(
"creator:林静文,autoCreator:huangchengcheng"
)
@allure.title
(
"{indata[testPoint]}"
)
@pytest.mark.parametrize
(
"indata"
,
getExcelData
.
get_excelData
(
workbook
,
"非交通占用道路审查"
,
"roadaddpFile"
))
def
test_
croadaddFile
(
self
,
indata
):
def
test_
roadaddfile
(
self
,
indata
,
roadaddbasicinfo
):
url
=
f
'{config.BMCConfig.host}/{indata["url"]}'
expectdata
=
indata
[
"expectData"
]
method
=
indata
[
"method"
]
mysql
=
MYSQL
(
"10.197.236.190"
,
3306
,
"root"
,
"123456"
,
db
=
"db_gy_dmsmp"
)
basic_info_id
=
mysql
.
ExecuQuery
(
"select id from db_gy_dmsmp.occupy_road_apply where user_id=393038 and people_phone='18800000044'order by id;"
)[
-
1
][
"id"
]
indata
[
"reqData"
][
"id"
]
=
basic_info_id
indata
[
"reqData"
][
"id"
]
=
roadaddbasicinfo
data
=
indata
[
"reqData"
]
res
=
request_main
(
url
,
self
.
headers
,
method
,
data
)
try
:
...
...
@@ -150,10 +171,11 @@ class TestRoadreview:
@allure.story
(
"申请详情"
)
@allure.description
(
"creator:林静文,autoCreator:huangchengcheng"
)
@allure.title
(
"{indata[testPoint]}"
)
@pytest.mark.parametrize
(
"indata"
,
getExcelData
.
get_excelData
(
workbook
,
"非交通占用道路审查"
,
"roaddetail
t
"
))
def
test_roaddetail
(
self
,
indata
):
@pytest.mark.parametrize
(
"indata"
,
getExcelData
.
get_excelData
(
workbook
,
"非交通占用道路审查"
,
"roaddetail"
))
def
test_roaddetail
(
self
,
indata
,
roadaddbasicinfo
):
url
=
f
'{config.BMCConfig.host}/{indata["url"]}'
data
=
indata
[
"reqData"
]
indata
[
"reqData"
][
"id"
]
=
roadaddbasicinfo
data
=
indata
[
"reqData"
]
expectdata
=
indata
[
"expectData"
]
method
=
indata
[
"method"
]
res
=
request_main
(
url
,
self
.
headers
,
method
,
data
)
...
...
@@ -167,9 +189,10 @@ class TestRoadreview:
@allure.description
(
"creator:林静文,autoCreator:huangchengcheng"
)
@allure.title
(
"{indata[testPoint]}"
)
@pytest.mark.parametrize
(
"indata"
,
getExcelData
.
get_excelData
(
workbook
,
"非交通占用道路审查"
,
"roadreSubmit"
))
def
test_roadresubmit
(
self
,
indata
):
def
test_roadresubmit
(
self
,
indata
,
roadaddbasicinfo
):
url
=
f
'{config.BMCConfig.host}/{indata["url"]}'
data
=
indata
[
"reqData"
]
indata
[
"reqData"
][
"id"
]
=
roadaddbasicinfo
data
=
indata
[
"reqData"
]
expectdata
=
indata
[
"expectData"
]
method
=
indata
[
"method"
]
res
=
request_main
(
url
,
self
.
headers
,
method
,
data
)
...
...
@@ -183,9 +206,10 @@ class TestRoadreview:
@allure.description
(
"creator:林静文,autoCreator:huangchengcheng"
)
@allure.title
(
"{indata[testPoint]}"
)
@pytest.mark.parametrize
(
"indata"
,
getExcelData
.
get_excelData
(
workbook
,
"非交通占用道路审查"
,
"roadnoticeDetail"
))
def
test_roadnoticedetail
(
self
,
indata
):
def
test_roadnoticedetail
(
self
,
indata
,
roadaddbasicinfo
):
url
=
f
'{config.BMCConfig.host}/{indata["url"]}'
data
=
indata
[
"reqData"
]
indata
[
"reqData"
][
"id"
]
=
roadaddbasicinfo
data
=
indata
[
"reqData"
]
expectdata
=
indata
[
"expectData"
]
method
=
indata
[
"method"
]
res
=
request_main
(
url
,
self
.
headers
,
method
,
data
)
...
...
@@ -213,7 +237,7 @@ class TestRoadreview:
def
teardown_class
(
self
):
mysql
=
MYSQL
(
"10.197.236.190"
,
3306
,
"root"
,
"123456"
,
db
=
"db_gy_dmsmp"
)
mysql
.
ExecuNonQuery
(
"delete from db_gy_dmsmp.occupy_road_apply where user_id='393038' and people_phone='18800000044'
and road_remark='这是接口自动化数据'
;"
)
mysql
.
ExecuNonQuery
(
"delete from db_gy_dmsmp.occupy_road_apply where user_id='393038' and people_phone='18800000044' ;"
)
...
...
@@ -223,6 +247,6 @@ class TestRoadreview:
#
# # 生成报告数据
# pytest.main(['-v', '-s', "test_roadreview.py", '--alluredir', './bmc/report',"--clean-alluredir"])
# # pytest.main(['-v', '-s', "test_roadreview.py::TestRoadreview::test_road
addbasicinfo
", '--alluredir', './bmc/report', "--clean-alluredir"])
# # pytest.main(['-v', '-s', "test_roadreview.py::TestRoadreview::test_road
detail
", '--alluredir', './bmc/report', "--clean-alluredir"])
# # 打开报告
# os.system('allure serve ./bmc/report')
\ No newline at end of file
test_case_data/bmc/bmc_home_basic_functions_2021513.xlsx
View file @
9a11bf2b
No preview for this file type
test_case_data/bmc/bmc_my_2021513.xlsx
View file @
9a11bf2b
No preview for this file type
test_case_data/bmc/bmc_road_review_2021513.xlsx
View file @
9a11bf2b
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