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
0aeffbe1
Commit
0aeffbe1
authored
May 18, 2021
by
fanxun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
三车用例完善1
parent
5c9b154a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
15 deletions
+52
-15
test_case/bmc/test_illegalstudy.py
+52
-15
test_case_data/bmc/bmc_testcase01_20210513.xlsx
+0
-0
No files found.
test_case/bmc/test_illegalstudy.py
View file @
0aeffbe1
__author__
=
'fanxun'
__data__
=
"2021-05-17 15:11"
import
pytest
,
allure
,
xlrd
,
os
import
pytest
,
allure
,
xlrd
,
os
,
random
import
config
from
common.utils.getExcelData
import
get_excelData
from
common.tools
import
request_main
...
...
@@ -24,7 +24,7 @@ class TestCreditScore():
# expectData = inData['expectData']
# res = request_main(url=url, headers=None, method=method, data=req_data, has_token=True)
# assert res['code'] == expectData['code']
#
#
#
# @allure.story("获取典型案例视频")
# @allure.link("http://yapi.hikcreate.com/project/31/interface/api/57606")
# @allure.description("/illegal/study/video/typicalCase")
...
...
@@ -49,28 +49,39 @@ class TestCreditScore():
req_data
=
inData
[
'reqData'
]
expectData
=
inData
[
'expectData'
]
res
=
request_main
(
url
=
url
,
headers
=
None
,
method
=
method
,
data
=
req_data
,
has_token
=
True
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
@pytest.fixture
()
def
test_pre_get_paper_illegal_study
(
self
):
"""获取试卷套件"""
url
=
f
"{BMCConfig().host}/paper/getPaper"
method
=
'get'
req_data
=
None
res
=
request_main
(
url
=
url
,
headers
=
None
,
method
=
method
,
data
=
req_data
,
has_token
=
True
)
topic_lists
=
res
[
'data'
][
'topicList'
]
self
.
browsequestion
=
{}
self
.
choosequestion
=
{}
self
.
browsequestion
[
'answerId'
]
=
res
[
'data'
][
'answerId'
]
self
.
choosequestion
[
'answerId'
]
=
res
[
'data'
][
'answerId'
]
browsequestion
=
{}
choosequestion
=
{}
browsequestion
[
'answerId'
]
=
res
[
'data'
][
'answerId'
]
choosequestion
[
'answerId'
]
=
res
[
'data'
][
'answerId'
]
for
item
in
topic_lists
:
if
item
[
'topicType'
]
==
2
:
# 浏览题
self
.
browsequestion
[
'topicId'
]
=
item
[
'topicId'
]
self
.
browsequestion
[
'topicType'
]
=
item
[
'topicType'
]
elif
item
[
'topicType'
]
==
1
:
self
.
choosequestion
[
'topicId'
]
=
item
[
'topicId'
]
self
.
choosequestion
[
'topicType'
]
=
item
[
'topicType'
]
assert
res
[
'code'
]
==
expectData
[
'code'
]
if
item
[
'topicType'
]
==
2
and
len
(
browsequestion
)
==
1
:
# 浏览题
browsequestion
[
'topicId'
]
=
item
[
'topicId'
]
browsequestion
[
'topicType'
]
=
item
[
'topicType'
]
elif
item
[
'topicType'
]
==
1
and
len
(
choosequestion
)
==
1
:
choosequestion
[
'topicId'
]
=
item
[
'topicId'
]
choosequestion
[
'topicType'
]
=
item
[
'topicType'
]
return
browsequestion
,
choosequestion
@allure.story
(
"提交答案"
)
@allure.link
(
"http://yapi.hikcreate.com/project/31/interface/api/67473"
)
@allure.description
(
"/paper/submitAnswer"
)
@allure.title
(
"{inData[testPoint]}"
)
@pytest.mark.parametrize
(
"inData"
,
get_excelData
(
workBook
,
'三车违法学习'
,
'submitAnswerIllegalstudy'
)[
0
])
def
test_submitAnswerIllegalstudy
(
self
,
inData
):
@pytest.mark.usefixtures
(
'test_pre_get_paper_illegal_study'
)
@pytest.mark.parametrize
(
"inData"
,
get_excelData
(
workBook
,
'三车违法学习'
,
'submitAnswerIllegalstudy'
))
def
test_submitAnswerIllegalstudy
(
self
,
inData
,
test_pre_get_paper_illegal_study
):
browsequestion
,
choosequestion
=
test_pre_get_paper_illegal_study
url
=
f
"{BMCConfig().host}{inData['url']}"
method
=
inData
[
'method'
]
req_data
=
inData
[
'reqData'
]
...
...
@@ -78,6 +89,32 @@ class TestCreditScore():
req_data
[
'topicId'
]
=
self
.
browsequestion
[
'topicId'
]
req_data
[
'topicType'
]
=
self
.
browsequestion
[
'topicType'
]
expectData
=
inData
[
'expectData'
]
case_num
=
inData
[
'caseNum'
]
if
case_num
==
'submitAnswerIllegalstudy001'
:
req_data
[
'answerId'
]
=
browsequestion
[
'answerId'
]
req_data
[
'topicId'
]
=
browsequestion
[
'topicId'
]
elif
case_num
==
'submitAnswerIllegalstudy002'
:
req_data
[
'answerId'
]
=
browsequestion
[
'answerId'
]
while
True
:
topic_id
=
random
.
randint
(
1
,
100
)
if
topic_id
!=
browsequestion
[
'topicId'
]:
req_data
[
'topicId'
]
=
topic_id
break
elif
case_num
==
'submitAnswerIllegalstudy003'
:
req_data
[
'topicId'
]
=
browsequestion
[
'topicId'
]
while
True
:
answer_id
=
random
.
randint
(
1
,
100
)
if
answer_id
!=
browsequestion
[
'answerId'
]:
req_data
[
'answerId'
]
=
answer_id
break
elif
case_num
==
'submitAnswerIllegalstudy004'
:
req_data
[
'answerId'
]
=
browsequestion
[
'answerId'
]
req_data
[
'topicId'
]
=
browsequestion
[
'topicId'
]
req_data
[
'topicType'
]
=
1
elif
case_num
==
'submitAnswerIllegalstudy005'
:
req_data
[
'answerId'
]
=
choosequestion
[
'answerId'
]
req_data
[
'topicId'
]
=
choosequestion
[
'topicId'
]
res
=
request_main
(
url
=
url
,
headers
=
None
,
method
=
method
,
data
=
req_data
,
has_token
=
True
)
assert
res
[
'code'
]
==
expectData
[
'code'
]
...
...
test_case_data/bmc/bmc_testcase01_20210513.xlsx
View file @
0aeffbe1
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