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
ea558367
Commit
ea558367
authored
Aug 24, 2021
by
taoke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[交委项目]添加新增风险点用例
parent
ffb55706
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
37 deletions
+88
-37
test_case/safe_transportation/jgd/test_riskManagement.py
+88
-37
test_case_data/safe_transportation/jgd_riskCase.xlsx
+0
-0
No files found.
test_case/safe_transportation/jgd/test_riskManagement.py
View file @
ea558367
# autor: taoke
# time : 2021/8/23 13:46
from
config
import
*
import
requests
,
pytest
import
requests
,
pytest
,
allure
,
xlrd
from
common.tools
import
request_main
from
common.utils.getExcelData
import
get_excelData
from
common.db
import
MYSQL
# class Test_Model():
# def test_qyd(self):
# print("测试")
# """直接拿token"""
# # bmy_token=SafeTransportationConfig.bmy_token
# # bmy_headers = {"Content-Type": "application/json",
# # "Authorization": bmy_token,
# # "appCode": "1422744796822036481"}
# # res=requests.post("http://testyun.banmago.com/api/tbd/web/baseData/intoVehicle/list",
# # json={"appCode":"1422744796822036481","pageNum":1,"pageSize":10,"useNaturePropertyIds":[]},
# # headers=bmy_headers)
# # print(res.json())
#
# """使用公共方法"""
# res=request_main("http://testyun.banmago.com/api/tbd/web/baseData/intoVehicle/list",
# "",
# "POST",
# {"appCode":"1422744796822036481","pageNum":1,"pageSize":10,"useNaturePropertyIds":[]})
# print(res)
#
# def test_jgd(self):
# print("测试")
# # """直接拿token"""
# # sso_token=SafeTransportationConfig.sso_token
# # headers = {"Content-Type": "application/json",
# # "token": sso_token}
# # res=requests.post("http://testtbdzj.hikcreate.com/web/warnPoint/pageList",
# # json={"pageNum":1,"pageSize":10},
# # headers=headers)
# # print(res.json())
#
# """使用公共方法"""
# res=request_main("http://testtbdzj.hikcreate.com/web/warnPoint/pageList",
# "",
# "POST",
# {"pageNum":1,"pageSize":10})
# print(res)
class
TestRiskManagement
():
def
test_qyd
(
self
):
print
(
"测试"
)
"""直接拿token"""
# bmy_token=SafeTransportationConfig.bmy_token
# bmy_headers = {"Content-Type": "application/json",
# "Authorization": bmy_token,
# "appCode": "1422744796822036481"}
# res=requests.post("http://testyun.banmago.com/api/tbd/web/baseData/intoVehicle/list",
# json={"appCode":"1422744796822036481","pageNum":1,"pageSize":10,"useNaturePropertyIds":[]},
# headers=bmy_headers)
# print(res.json())
@pytest.fixture
(
scope
=
"class"
)
def
riskPointdelete
():
"""删除测试数据"""
yield
mysql
=
MYSQL
(
*
BaseConfig
.
test_mysql
)
mysql
.
ExecuNonQuery
(
"delete from db_tbd_base1.risk_info where risk_name like '自动化新增
%
'"
)
"""使用公共方法"""
res
=
request_main
(
"http://testyun.banmago.com/api/tbd/web/baseData/intoVehicle/list"
,
""
,
"POST"
,
{
"appCode"
:
"1422744796822036481"
,
"pageNum"
:
1
,
"pageSize"
:
10
,
"useNaturePropertyIds"
:[]})
print
(
res
)
def
test_jgd
(
self
):
print
(
"测试"
)
# """直接拿token"""
# sso_token=SafeTransportationConfig.sso_token
# headers = {"Content-Type": "application/json",
# "token": sso_token}
# res=requests.post("http://testtbdzj.hikcreate.com/web/warnPoint/pageList",
# json={"pageNum":1,"pageSize":10},
# headers=headers)
# print(res.json())
@pytest.mark.usefixtures
(
"riskPointdelete"
)
class
TestRiskMan
():
workBook
=
xlrd
.
open_workbook
(
f
'{BaseConfig.root_path}/test_case_data/safe_transportation/jgd_riskCase.xlsx'
)
@allure.story
(
"风险规则配置"
)
@allure.title
(
"{inData[testPoint]}"
)
@allure.testcase
(
"http://yapi.hikcreate.com/project/336/interface/api/73931"
)
@allure.description
(
"author:taoke"
)
@pytest.mark.parametrize
(
"inData"
,
get_excelData
(
workBook
,
"风险管理中心"
,
"riskSave"
))
def
test_riskPointsave
(
self
,
inData
):
url
=
f
"{SafeTransportationConfig().SSO_url}{inData['url']}"
headers
=
inData
[
'headers'
]
method
=
inData
[
'method'
]
data
=
inData
[
'reqData'
]
expectData
=
inData
[
'expectData'
]
res
=
request_main
(
url
,
headers
,
method
,
data
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
"""使用公共方法"""
res
=
request_main
(
"http://testtbdzj.hikcreate.com/web/warnPoint/pageList"
,
""
,
"POST"
,
{
"pageNum"
:
1
,
"pageSize"
:
10
})
print
(
res
)
@pytest.fixture
()
def
riskPointID
(
self
):
"""返回新增的测试数据的id"""
mysql
=
MYSQL
(
*
BaseConfig
.
test_mysql
)
info
=
mysql
.
ExecuQuery
(
"select id from db_tbd_base1.risk_info where risk_name='自动化新增';"
)
return
info
[
0
][
'id'
]
@allure.story
(
"风险规则配置"
)
@allure.title
(
"{inData[testPoint]}"
)
@allure.testcase
(
"http://yapi.hikcreate.com/project/336/interface/api/73931"
)
@allure.description
(
"author:taoke"
)
@pytest.mark.parametrize
(
"inData"
,
get_excelData
(
workBook
,
"风险管理中心"
,
"riskupdateSave"
))
def
test_riskupdateSave
(
self
,
inData
,
riskPointID
):
url
=
f
"{SafeTransportationConfig().SSO_url}{inData['url']}"
headers
=
inData
[
'headers'
]
method
=
inData
[
'method'
]
data
=
inData
[
'reqData'
]
expectData
=
inData
[
'expectData'
]
# 修改请求参数中的风险id
data
[
"riskPointRequest"
][
"riskId"
]
=
riskPointID
res
=
request_main
(
url
,
headers
,
method
,
data
)
allure
.
attach
(
f
"{res}"
,
"响应结果"
,
allure
.
attachment_type
.
TEXT
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
if
__name__
==
'__main__'
:
...
...
@@ -49,4 +100,4 @@ if __name__ == '__main__':
os
.
remove
(
f
'../../../report/tmp/{one}'
)
pytest
.
main
([
'test_riskManagement.py'
,
'-s'
,
'--alluredir'
,
'../../../report/tmp'
])
# 启动默认浏览器打开报告
# os.system('allure serve ../../../report/tmp')
\ No newline at end of file
os
.
system
(
'allure serve ../../../report/tmp'
)
\ No newline at end of file
test_case_data/safe_transportation/jgd_riskCase.xlsx
View file @
ea558367
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