Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test_platform
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Wallen姚文辉
test_platform
Commits
a759893b
Commit
a759893b
authored
Jun 14, 2024
by
Wallen姚文辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增接口测试报告
parent
1dc3c8ec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
Tool.py
controller/Tool.py
+30
-3
No files found.
controller/Tool.py
View file @
a759893b
...
...
@@ -12,7 +12,6 @@ from manager.tools import sqlOrmToJson
import
xmindparser
from
copy
import
deepcopy
from
manager.tools
import
par_path
import
os
from
threading
import
Thread
from
flask_socketio
import
emit
,
send
...
...
@@ -108,7 +107,6 @@ def reportinfo():
testcase
=
list
(
filter
(
lambda
x
:
type_
[
x
[
"typeId"
]]
==
"测试用例"
,
all_
))
keylist
=
list
(
map
(
lambda
x
:
x
.
get
(
"key"
),
testcase
))
for
i
in
story
:
print
(
i
)
i
[
"case"
]
=
[]
i
[
"childrenTask"
]
=
[
i
.
get
(
"key"
)]
chan
=
''
...
...
@@ -429,6 +427,35 @@ def test():
return
jsonify
({
"code"
:
200
,
"message"
:
"请求成功"
,
"data"
:
a
}),
200
@
tool
.
route
(
'/testport/getapitestinfo'
,
methods
=
[
"POST"
])
def
getapitestinfo
():
info
=
request
.
json
.
get
(
"data"
)
try
:
runinfo
=
{
"运行列表"
:[]}
soup
=
BeautifulSoup
(
info
,
"html.parser"
)
a
=
soup
.
find
(
class_
=
"container"
)
path
=
lambda
x
:
f
'div[class="card"]>div[class="card-body"]>div[class="row"]>div:-soup-contains("{x}")+div'
onlyinfolist
=
[
"测试场景"
,
"运行时间"
,
"总耗时"
,
"总返回数据"
,
"接口请求耗时"
,
"平均接口请求耗时"
,
"通过率"
,
"失败率"
,
"未测率"
]
twoinfolist
=
[
"循环数"
,
"HTTP 接口请求数"
,
"断言数"
]
[
runinfo
.
update
({
i
:
soup
.
select
(
path
(
i
))[
0
]
.
text
})
for
i
in
onlyinfolist
]
[
runinfo
.
update
({
i
:[
soup
.
select
(
path
(
i
))[
0
]
.
text
,
soup
.
select
(
path
(
i
)
+
'+div'
)[
0
]
.
text
]})
for
i
in
twoinfolist
]
for
each
in
a
.
select
(
"div[class='']>div[class='collapse']>div[class='']"
):
this
=
{
"step"
:[]}
k
=
each
.
find_all
(
'div'
,
recursive
=
False
)
this
[
"name"
]
=
k
[
0
]
.
text
.
strip
()
for
item
in
k
[
1
]
.
find_all
(
'div'
,
recursive
=
False
):
stepinfo
=
{
"断言详情"
:[]}
stepinfo
[
"name"
]
=
item
.
find
(
'h5'
)
.
text
.
strip
()
onlyinfolist
=
[
"Method"
,
"URL"
,
"耗时"
,
"返回数据"
,
"HTTP 状态码"
,
"断言通过数"
,
"断言失败数"
]
path
=
lambda
x
:
f
'div[class="card-body"]>div>div[class="row"]>div:-soup-contains("{x}")+div'
[
stepinfo
.
update
({
i
:
item
.
select
(
path
(
i
))[
0
]
.
text
})
for
i
in
onlyinfolist
]
stepinfo
[
"断言详情"
]
.
append
(
list
(
map
(
lambda
x
:
x
.
text
.
strip
(),
item
.
select
(
'div[class="card-body"]>div>div[class="row"]>div:-soup-contains("断言详情")+div>table>tbody>tr>td'
))))
this
[
"step"
]
.
append
(
stepinfo
)
runinfo
[
"运行列表"
]
.
append
(
this
)
return
jsonify
({
"code"
:
200
,
"message"
:
"请求成功"
,
"data"
:
runinfo
}),
200
except
:
return
jsonify
({
"code"
:
403
,
"message"
:
"文件内容有误,请确认"
}),
403
...
...
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