Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apiTest1.0
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangchunyao
apiTest1.0
Commits
c9adf357
Commit
c9adf357
authored
Jul 10, 2019
by
zhangchunyao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code commit
parent
2834ac3c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
0 deletions
+97
-0
interfacetest.py
interfacetest.py
+0
-0
resultMail.py
resultMail.py
+55
-0
runtest.py
runtest.py
+42
-0
No files found.
interfacetest.py
0 → 100644
View file @
c9adf357
This diff is collapsed.
Click to expand it.
resultMail.py
0 → 100644
View file @
c9adf357
#coding=utf-8
import
smtplib
from
email.mime.text
import
MIMEText
#MIMRText()定义邮件正文
from
email.mime.multipart
import
MIMEMultipart
#MIMEMulipart模块构造带附
def
sendResultMail
(
smtpSever
,
sendUser
,
sendPwd
,
recvUser
):
#发送邮件的服务器
#smtpserver = 'smtp.sina.com'
smtpserver
=
smtpSever
#发送邮件用户和密码
#user ="xxx@sina.com"
#password = "xxx"
user
=
sendUser
password
=
sendPwd
#发送者
#sender = "xxx@sina.com"
sender
=
sendUser
#接收者
#receiver = "1xxx@qq.com"
receiver
=
recvUser
#邮件主题
subject
=
"接口自动化执行结果"
#发送附件
sendfile
=
open
(
"/opt/apitest/interfacedata/apitest.xls"
,
"rb"
)
.
read
()
att
=
MIMEText
(
sendfile
,
"base64"
,
"utf-8"
)
att
[
"Content-Type"
]
=
"application/octet-stream"
att
[
"Content-Disposition"
]
=
"attachment;filename = 'autoInterfaceResult.xls'"
#msghtml = MIMEText('<h1 style="color:red;font-size:100px">各位好,附件为接口自动化测试详细结果,请查阅</h1><img src="cid:small">', 'html', 'utf-8')
msghtml
=
MIMEText
(
'<h2 style="color:red;font-size:50px">各位好,附件为接口自动化测试详细结果,请查阅</h2>'
,
'html'
,
'utf-8'
)
#msg = MIMEText('接口自动化测试结果', 'plain', 'utf-8')
msgRoot
=
MIMEMultipart
(
'related'
)
msgRoot
[
'Subject'
]
=
subject
msgRoot
[
'from'
]
=
"测试服务器"
msgRoot
[
'To'
]
=
receiver
msgRoot
.
attach
(
att
)
msgRoot
.
attach
(
msghtml
)
#msgRoot.attach(msg)
smtp
=
smtplib
.
SMTP
()
smtp
.
connect
(
smtpserver
)
smtp
.
login
(
user
,
password
)
smtp
.
sendmail
(
sender
,
receiver
,
msgRoot
.
as_string
())
smtp
.
quit
()
runtest.py
0 → 100644
View file @
c9adf357
#coding:utf-8
from
interfacetest
import
xlsx_open
from
interfacetest
import
xlsx_save
from
interfacetest
import
dosheet
from
xlutils.copy
import
copy
from
resultMail
import
sendResultMail
APIPATH
=
'/opt/apitest/interfacedata/apitest.xls'
# 打开文件
brd
=
xlsx_open
(
APIPATH
)
# copy文件用于写入结果a
bwt
=
copy
(
brd
)
# 获取cookie
# url = "http://xxx"
# data = {
# "name":"xxx",
# "password":"xxx"
# }
# response = requests.post(url,data)
# c = response.cookies
# cookies = dict(c)
# 执行文件
dosheet
(
brd
,
bwt
,
0
)
# dosheet(brd, bwt, 1, cookies)
# 保存
xlsx_save
(
bwt
,
APIPATH
)
smtpSer
=
"smtp.exmail.qq.com"
# 测试服务器群发测试组成员
sendUser
=
"apitest@demogic.com"
sendPwd
=
"Api@201906"
recvUser
=
"test@demogic.com"
#recvUser = "lienlin@demogic.com"
#recvUser = "zhangchunyao@demogic.com"
sendResultMail
(
smtpSer
,
sendUser
,
sendPwd
,
recvUser
)
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