liumiaomiao 2 年之前
父節點
當前提交
679951ec1b
共有 4 個文件被更改,包括 94 次插入1 次删除
  1. 6 0
      .idea/vcs.xml
  2. 21 0
      cases/订阅/push_list.py
  3. 58 0
      doc/sendemail.py
  4. 9 1
      lib/webapi.py

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 21 - 0
cases/订阅/push_list.py

@@ -0,0 +1,21 @@
+from hytest import *
+from lib.webapi import apimgr
+class c1:
+    #测试用例名称
+    name='推送记录接口验证'
+    # 初始化方法
+    def setup(self):
+        INFO('初始化方法')
+    #测试步骤
+    def teststeps(self):
+        INFO('测试步骤')
+        STEP(1,'第一步调用函数')    #会出现在测试报告中
+        r = apimgr.push_list()
+        res = r.json()
+        actural = res['data']['count']
+        STEP(2,'第二步设置检查点')
+        #设置检查点
+        CHECK_POINT('检查推动记录接口是否正常',actural != 0 )
+    #清除方法
+    def teardown(self):
+        INFO('清除方法')

+ 58 - 0
doc/sendemail.py

@@ -0,0 +1,58 @@
+import smtplib
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
+import os
+import datetime
+def find_newest_file(current_dir):
+    # 获取当前目录中所有文件的信息
+    files = os.listdir(current_dir)
+    # 初始化最近修改时间和对应的文件名
+    latest_time = None
+    latest_file = None
+    # 遍历所有文件
+    for file in files:
+        # 获取文件的路径
+        file_path = os.path.join(current_dir, file)
+        # 如果是文件而不是文件夹
+        if os.path.isfile(file_path):
+            # 获取文件的最后修改时间
+            modification_time = os.path.getmtime(file_path)
+            # 将修改时间转换为可读格式
+            modification_time = datetime.datetime.fromtimestamp(modification_time)
+            # 判断是否是第一个文件或者当前文件的修改时间更晚
+            if (latest_time is None or modification_time > latest_time) and file_path.endswith('.html'):
+                latest_time = modification_time
+                latest_file = file
+    return latest_file
+
+
+#发送邮件
+def send_email(report_name):
+    #定义SMTP的服务器
+    smtpserver='smtp.163.com'
+    #发送邮件的用户名和客户端密码
+    username="liumm_6064@163.com"
+    password="TPVBPYSETVHWTIDH"
+    #接受邮件的邮箱
+    receiver=['liumiaomiao@topnet.net.cn','lizhikun@topnet.net.cn']
+    #创建邮件对象
+    message=MIMEMultipart('related')
+    #邮件主题
+    subject="剑鱼自动化测试报告"
+    fujian=MIMEText(open(f'/Users/miaobao/Documents/work/autoproject/jianyu_auto_api/log/{report_name}','rb').read(),'html','utf-8')
+    #把邮件信息组装到邮件对象里面
+    message['from']=username
+    message['to']= ",".join(receiver)
+    message['subject']=subject
+    message.attach(fujian)
+    #登录smtp服务器并发送邮件
+    smtp=smtplib.SMTP()
+    smtp.connect(smtpserver)
+    smtp.login(username,password)
+    smtp.sendmail(username,receiver,message.as_string())
+    smtp.quit()
+if __name__ == '__main__':
+    dir = r'/Users/miaobao/Documents/work/autoproject/jianyu_auto_api/log'
+    filename = find_newest_file(dir)
+    if filename:
+        send_email(filename)

+ 9 - 1
lib/webapi.py

@@ -54,5 +54,13 @@ class APIMgr():
         self.printResponse(response)
         # 把response对象返回出去
         return response
-    #函数
+    #获取推送记录接口
+    def push_list(self):
+        headers=GSTORE['headers']
+        response = self.s.post(f"{cfg.target_host}/jyapi/jybx/subscribe/fType/list",headers=headers,json=
+                         {"pageNum": 1, "pageSize": 50, "format": "table", "area": "", "selectTime": "all", "city": "", "buyerClass": "",
+                            "subtype": "", "industry": "", "keyWords": "", "fileExists": "", "price": "", "source": "", "exportNum": "",
+                            "vt": ""})
+        return  response
+
 apimgr = APIMgr()