Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhangjingdong
/
bihe_interface_test
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d558cffc
authored
Jan 14, 2019
by
zhangjingdong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试服务器发送邮件
parent
7bdb235f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
62 deletions
+57
-62
.idea/workspace.xml
+12
-12
碧合app/execute_automation_scripts.py
+45
-50
No files found.
.idea/workspace.xml
View file @
d558cffc
...
...
@@ -13,7 +13,7 @@
</component>
<component
name=
"CoverageDataManager"
>
<SUITE
FILE_PATH=
"coverage/bihe_interface_test$hebin.coverage"
NAME=
"hebin Coverage Results"
MODIFIED=
"1547019882690"
SOURCE_PROVIDER=
"com.intellij.coverage.DefaultCoverageFileProvider"
RUNNER=
"coverage.py"
COVERAGE_BY_TEST_ENABLED=
"true"
COVERAGE_TRACING_ENABLED=
"false"
WORKING_DIRECTORY=
"$PROJECT_DIR$/碧合app"
/>
<SUITE
FILE_PATH=
"coverage/bihe_interface_test$execute_automation_scripts.coverage"
NAME=
"execute_automation_scripts Coverage Results"
MODIFIED=
"154743
3958255
"
SOURCE_PROVIDER=
"com.intellij.coverage.DefaultCoverageFileProvider"
RUNNER=
"coverage.py"
COVERAGE_BY_TEST_ENABLED=
"true"
COVERAGE_TRACING_ENABLED=
"false"
WORKING_DIRECTORY=
"$PROJECT_DIR$/碧合app"
/>
<SUITE
FILE_PATH=
"coverage/bihe_interface_test$execute_automation_scripts.coverage"
NAME=
"execute_automation_scripts Coverage Results"
MODIFIED=
"154743
4463013
"
SOURCE_PROVIDER=
"com.intellij.coverage.DefaultCoverageFileProvider"
RUNNER=
"coverage.py"
COVERAGE_BY_TEST_ENABLED=
"true"
COVERAGE_TRACING_ENABLED=
"false"
WORKING_DIRECTORY=
"$PROJECT_DIR$/碧合app"
/>
</component>
<component
name=
"FavoritesManager"
>
<favorites_list
name=
"bihe_interface_test"
/>
...
...
@@ -23,11 +23,11 @@
<file
leaf-file-name=
"execute_automation_scripts.py"
pinned=
"false"
current-in-tab=
"true"
>
<entry
file=
"file://$PROJECT_DIR$/碧合app/execute_automation_scripts.py"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
265
"
>
<caret
line=
"
53"
column=
"47"
lean-forward=
"true"
selection-start-line=
"53"
selection-start-column=
"47"
selection-end-line=
"53"
selection-end-column=
"47
"
/>
<state
relative-caret-position=
"
-743
"
>
<caret
line=
"
14"
column=
"35"
selection-start-line=
"14"
selection-start-column=
"35"
selection-end-line=
"14"
selection-end-column=
"35
"
/>
<folding>
<element
signature=
"e#19#30#0"
expanded=
"true"
/>
<marker
date=
"1547434
080275"
expanded=
"true"
signature=
"2740:3714
"
ph=
"..."
/>
<marker
date=
"1547434
480403"
expanded=
"true"
signature=
"2655:3690
"
ph=
"..."
/>
</folding>
</state>
</provider>
...
...
@@ -369,7 +369,7 @@
<caret
line=
"10"
column=
"49"
lean-forward=
"true"
selection-start-line=
"10"
selection-start-column=
"49"
selection-end-line=
"10"
selection-end-column=
"49"
/>
<folding>
<element
signature=
"e#19#30#0"
expanded=
"true"
/>
<marker
date=
"1547434
080275"
expanded=
"true"
signature=
"2740:3714
"
ph=
"..."
/>
<marker
date=
"1547434
480403"
expanded=
"true"
signature=
"2655:3690
"
ph=
"..."
/>
</folding>
</state>
</provider>
...
...
@@ -422,7 +422,7 @@
<caret
line=
"11"
column=
"49"
lean-forward=
"true"
selection-start-line=
"11"
selection-start-column=
"49"
selection-end-line=
"11"
selection-end-column=
"49"
/>
<folding>
<element
signature=
"e#19#30#0"
expanded=
"true"
/>
<marker
date=
"1547434
080275"
expanded=
"true"
signature=
"2740:3714
"
ph=
"..."
/>
<marker
date=
"1547434
480403"
expanded=
"true"
signature=
"2655:3690
"
ph=
"..."
/>
</folding>
</state>
</provider>
...
...
@@ -439,7 +439,7 @@
<caret
line=
"15"
column=
"32"
lean-forward=
"true"
selection-start-line=
"15"
selection-start-column=
"32"
selection-end-line=
"15"
selection-end-column=
"32"
/>
<folding>
<element
signature=
"e#19#30#0"
expanded=
"true"
/>
<marker
date=
"1547434
080275"
expanded=
"true"
signature=
"2740:3714
"
ph=
"..."
/>
<marker
date=
"1547434
480403"
expanded=
"true"
signature=
"2655:3690
"
ph=
"..."
/>
</folding>
</state>
</provider>
...
...
@@ -457,7 +457,7 @@
<caret
line=
"14"
column=
"25"
selection-start-line=
"14"
selection-start-column=
"25"
selection-end-line=
"14"
selection-end-column=
"25"
/>
<folding>
<element
signature=
"e#19#30#0"
expanded=
"true"
/>
<marker
date=
"1547434
080275"
expanded=
"true"
signature=
"2740:3714
"
ph=
"..."
/>
<marker
date=
"1547434
480403"
expanded=
"true"
signature=
"2655:3690
"
ph=
"..."
/>
</folding>
</state>
</provider>
...
...
@@ -480,7 +480,7 @@
<caret
line=
"8"
column=
"8"
lean-forward=
"true"
selection-start-line=
"8"
selection-start-column=
"8"
selection-end-line=
"8"
selection-end-column=
"8"
/>
<folding>
<element
signature=
"e#19#30#0"
expanded=
"true"
/>
<marker
date=
"1547434
080275"
expanded=
"true"
signature=
"2740:3714
"
ph=
"..."
/>
<marker
date=
"1547434
480403"
expanded=
"true"
signature=
"2655:3690
"
ph=
"..."
/>
</folding>
</state>
</provider>
...
...
@@ -589,11 +589,11 @@
</entry>
<entry
file=
"file://$PROJECT_DIR$/碧合app/execute_automation_scripts.py"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"
265
"
>
<caret
line=
"
53"
column=
"47"
lean-forward=
"true"
selection-start-line=
"53"
selection-start-column=
"47"
selection-end-line=
"53"
selection-end-column=
"47
"
/>
<state
relative-caret-position=
"
-743
"
>
<caret
line=
"
14"
column=
"35"
selection-start-line=
"14"
selection-start-column=
"35"
selection-end-line=
"14"
selection-end-column=
"35
"
/>
<folding>
<element
signature=
"e#19#30#0"
expanded=
"true"
/>
<marker
date=
"1547434
080275"
expanded=
"true"
signature=
"2740:3714
"
ph=
"..."
/>
<marker
date=
"1547434
480403"
expanded=
"true"
signature=
"2655:3690
"
ph=
"..."
/>
</folding>
</state>
</provider>
...
...
碧合app/execute_automation_scripts.py
View file @
d558cffc
# cod
ing = utf-8
# cod
ing = utf-8
...
...
@@ -13,11 +13,6 @@ from email.header import Header
class
PostmanApi
():
def
endWith
(
self
,
s
,
*
endstring
):
"""
:param s:
:param endstring:
:return
"""
array
=
map
(
s
.
endswith
,
endstring
)
if
True
in
array
:
return
True
...
...
@@ -49,7 +44,7 @@ class PostmanApi():
message
[
'From'
]
=
Header
(
"测试环境接口自动化测试"
)
message
[
'Subject'
]
=
Header
(
years
+
at_the
+
"自动化测试结果"
,
'utf-8'
)
try
:
smtpObj
=
smtplib
.
SMTP_SSL
(
mail_host
,
465
)
smtpObj
=
smtplib
.
SMTP_SSL
(
mail_host
,
465
)
# smtpObj.connect(mail_host,587 ) # 25 为 SMTP 端口号
smtpObj
.
login
(
mail_user
,
mail_pass
)
smtpObj
.
sendmail
(
sender
,
receivers
,
message
.
as_string
())
...
...
@@ -76,49 +71,49 @@ class PostmanApi():
successful
=
0
failure
=
0
for
p
in
path
:
if
os
.
path
.
isdir
(
p
):
file
.
append
(
p
)
for
file_path
in
file
:
# 当天日期
now_date
=
report_file
+
years
# 目前时分
now_module
=
now_date
+
"/"
+
at_the
# 文件完整路径
now_time
=
now_module
+
"/"
+
file_path
+
'.html'
execute
=
PostmanApi
()
.
full_path
(
BASE_DIR
,
file_path
,
delay_request
,
timeout_request
,
now_time
)
if
(
os
.
path
.
exists
(
now_date
)):
if
(
os
.
path
.
exists
(
now_module
)):
os
.
system
(
execute
)
else
:
os
.
system
(
"mkdir "
+
now_module
)
os
.
system
(
execute
)
else
:
os
.
system
(
"mkdir "
+
now_date
)
if
(
os
.
path
.
exists
(
now_module
)):
os
.
system
(
execute
)
else
:
os
.
system
(
"mkdir "
+
now_module
)
os
.
system
(
execute
)
for
item
in
os
.
listdir
(
extract_data
):
if
PostmanApi
()
.
endWith
(
item
,
'.html'
):
# print(item)
with
open
(
extract_data
+
"/"
+
item
,
'rU'
)
as
strf
:
str1
=
strf
.
read
()
res_2
=
r'Test Scripts</div><div class="col-md-4">(.+?)</div><div class="col-md-4">(.+?)</div>'
pile1
=
re
.
compile
(
res_2
)
li
=
re
.
findall
(
pile1
,
str1
)
li1
=
str
(
li
[
0
][
0
])
li2
=
str
(
li
[
0
][
1
])
successful
+=
int
(
li
[
0
][
0
])
failure
+=
int
(
li
[
0
][
1
])
report
=
""
report_text
+=
report
.
join
(
" 模块:"
+
item
[:
-
5
]
+
" 数量:"
+
li1
+
" 失败:"
+
li2
+
"
\n
"
)
report_text1
=
" 接口数量:"
+
str
(
successful
)
+
" 失败数量:"
+
str
(
failure
)
#
for p in path:
#
if os.path.isdir(p):
#
file.append(p)
#
for file_path in file:
#
# 当天日期
#
now_date = report_file + years
#
# 目前时分
#
now_module = now_date + "/" + at_the
#
# 文件完整路径
#
now_time = now_module + "/" + file_path + '.html'
#
execute = PostmanApi().full_path(
#
BASE_DIR, file_path, delay_request, timeout_request, now_time
#
)
#
#
if (os.path.exists(now_date)):
#
if (os.path.exists(now_module)):
#
os.system(execute)
#
else:
#
os.system("mkdir " + now_module)
#
os.system(execute)
#
else:
#
os.system("mkdir " + now_date)
#
if (os.path.exists(now_module)):
#
os.system(execute)
#
else:
#
os.system("mkdir " + now_module)
#
os.system(execute)
#
#
for item in os.listdir(extract_data):
#
if PostmanApi().endWith(item, '.html'):
#
# print(item)
#
with open(extract_data+"/"+item, 'rU') as strf:
#
str1 = strf.read()
#
res_2 = r'Test Scripts</div><div class="col-md-4">(.+?)</div><div class="col-md-4">(.+?)</div>'
#
pile1 =re.compile(res_2)
#
li = re.findall(pile1, str1)
#
li1 = str(li[0][0])
#
li2 = str(li[0][1])
#
successful += int(li[0][0])
#
failure += int(li[0][1])
#
report = ""
#
report_text+=report.join(" 模块:"+item[:-5]+" 数量:"+li1+" 失败:"+li2+"\n")
#
report_text1 = " 接口数量:"+str(successful)+" 失败数量:"+str(failure)
PostmanApi
()
.
report_mail
(
years
,
report_text1
,
report_text
,
at_the
,
report_file
)
return
self
...
...
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