Commit d558cffc by zhangjingdong

测试服务器发送邮件

parent 7bdb235f
......@@ -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="1547433958255" 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="1547434463013" 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="1547434080275" expanded="true" signature="2740:3714" ph="..." />
<marker date="1547434480403" 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="1547434080275" expanded="true" signature="2740:3714" ph="..." />
<marker date="1547434480403" 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="1547434080275" expanded="true" signature="2740:3714" ph="..." />
<marker date="1547434480403" 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="1547434080275" expanded="true" signature="2740:3714" ph="..." />
<marker date="1547434480403" 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="1547434080275" expanded="true" signature="2740:3714" ph="..." />
<marker date="1547434480403" 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="1547434080275" expanded="true" signature="2740:3714" ph="..." />
<marker date="1547434480403" 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="1547434080275" expanded="true" signature="2740:3714" ph="..." />
<marker date="1547434480403" expanded="true" signature="2655:3690" ph="..." />
</folding>
</state>
</provider>
......
# coding = utf-8
# coding = 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment