def test1(self, case_des, doc, type, code, result, returnType, productType, clt, doc1, login): print('测试开始!') # a = 'loginByEmail' # b = {'email': '*****@*****.**', 'password': '******', 'userType': '1', 'clt': 'h5Wealth'} host = self.host = read_Config.ReadConfig().get_config_str( 'HOST', 'host') url = ''.join([host, doc]) par = { 'clt': clt, 'returnType': returnType, 'productType': productType, 'token': base.get_token_ok(doc1, login) } resp = base.method(url, method=type, data=par) # print(resp) dd = resp['data'] print(dd) aa = dd[1]['id'] # infolist = [] # for row in range(1,self.rows): # info = self.sheet.row_values(row) # infolist.append(info) print(aa) #self.assertTrue(resp[code] == result) self.assertEqual(resp[code], result, msg='返回值错误') print('测试完成!')
def setUp(self): self.url1 = 'https://api.haitoutech.com/haitou-user/userInfo/queryUserInfoForWealth' # self.url2 = 'https://api.haitoutech.com/haitou-order/assetsStatistic/queryAssetsStatisticsForAll' # self.url3 = 'https://api.haitoutech.com/haitou-order/moneyFund/queryUserSetting' # self.url4 = 'https://api.haitoutech.com/haitou-order/moneyFund/queryUserAccount' # self.url5 = 'https://api.haitoutech.com/haitou-order/moneyFund/queryOrderList' # self.url6 = 'https://api.haitoutech.com/haitou-order/moneyFund/queryAccountEarningsList' # self.url7 = 'https://api.haitoutech.com/haitou-user/userInfo/queryUserInfoForWealth' self.host = read_Config.ReadConfig().get_config('HOST', 'host')
def send_mail(filename): #定义邮件标题 # mail_host = 'smtp.qiye.163.com' # mail_user = '******' # mail_pass = '******' # sender = '*****@*****.**' # mail_host = ('smtp.qq.com') # mail_user = '******' # mail_pass = '******' # sender = '*****@*****.**' # receivers = ['*****@*****.**','*****@*****.**'] mail_config = read_Config.ReadConfig() mail_host = mail_config.get_config_str('EMAIL','mail_host') print(mail_host) # mail_user = mail_config.get_config('EMAIL','mail_user') mail_pass = mail_config.get_config_str('EMAIL','mail_pass') sender = mail_config.get_config_str('EMAIL','sender') # receivers1 = mail_config.get_config_str('EMAIL','receivers1') # receivers2 = mail_config.get_config_str('EMAIL','receivers2') receivers = mail_config.get_config_str('EMAIL','receivers') receivers1 = "*****@*****.**" receivers2 = "*****@*****.**" receivers = eval(receivers) print(receivers) message=MIMEMultipart('related') #读取报告 f=open(filename,'rb') mail_body = f.read() att = MIMEText(mail_body,'base64','utf-8') att['Content-Type'] = 'application/octet-stream' att['Content-Disposition'] = 'attachment;filename="report.html"' message.attach(att) f.close() #定义邮件正文,报告以正文的形式发送 msg = MIMEText(mail_body,'html','utf-8') message.attach(msg) message['From']=sender message['To']=','.join(receivers) print(message['To']) message['Subject']=Header(mail_config.get_config_str('EMAIL','subject'),'utf-8') smtp=smtplib.SMTP() smtp.connect(mail_host) smtp.login(sender,mail_pass) smtp.sendmail(sender,receivers,message.as_string()) smtp.quit() # print("测试报告邮件已发送至" + json.dumps(receivers)) print("测试报告邮件已发送至" + str(receivers)) print("email has send out")
def send_mail(filename): #定义邮件标题 # mail_host = 'smtp.qiye.163.com' # mail_user = '******' # mail_pass = '******' # sender = '*****@*****.**' # mail_host = ('smtp.qq.com') # mail_user = '******' # mail_pass = '******' # sender = '*****@*****.**' # receivers = ['*****@*****.**','*****@*****.**'] mail_config = read_Config.ReadConfig() mail_host = mail_config.get_config_str('EMAIL', 'mail_host') print(mail_host) # mail_user = mail_config.get_config('EMAIL','mail_user') mail_pass = mail_config.get_config_str('EMAIL', 'mail_pass') sender = mail_config.get_config_str('EMAIL', 'sender') receivers1 = mail_config.get_config_str('EMAIL', 'receivers1') receivers2 = mail_config.get_config_str('EMAIL', 'receivers2') receivers = [receivers1, receivers2] # message=MIMEMultipart('related') # #读取报告 # f=open(filename,'rb') # mail_body = f.read() # att = MIMEText(mail_body,'base64','utf-8') # att['Content-Type'] = 'application/octet-stream' # att['Content-Disposition'] = 'attachment;filename="report.html"' # message.attach(att) # f.close() # 链接邮箱服务器 yag = yagmail.SMTP(user=sender, password=mail_pass, host=mail_host) # 邮箱正文 contents = [ 'This is the body, and here is just text http://somedomain/image.png', 'You can find an audio file attached.', '/local/path/song.mp3' ] # 发送邮件 # yag.send(receiver @ qq.com', 'subject', contents) # yag.send(['*****@*****.**', '*****@*****.**', '*****@*****.**'], 'subject', contents) yag.send('*****@*****.**', '发送附件', contents, ["E://whitelist.txt", "E://baidu_img.jpg"]) print("测试报告邮件已发送至" + json.dumps(receivers)) print("email has send out")
def Run(testcase): #构建测试集 test_dir = os.path.join(path, testcase) discover = unittest.defaultTestLoader.discover(test_dir, pattern='test*.py') f = base.fp() fp = open(f, "wb") mail_config = read_Config.ReadConfig() title = mail_config.get_config_str('EMAIL', 'title') description = mail_config.get_config_str('EMAIL', 'description') tester = mail_config.get_config_str('EMAIL', 'tester') runner = HTMLTestRunnerCN.HTMLTestRunner(stream=fp, title=title, description=description, verbosity=2, tester=tester) runner.run(discover) fp.close() test_report = os.path.join(path, "report") rep = base.report(test_report) #发送邮件 send_mail.send_mail(rep)
#!/usr/bin/python # -*- coding: UTF-8 -*- import records from oper import read_Config config = read_Config.ReadConfig() # encoding=utf-8 def db_read(): host = config.get_config_str('DATABASE', 'host') # port = config.get_config_int('DATABASE', 'port') port = config.get_config_str('DATABASE', 'port') #这里端口号因为是跟其他参数一个整体,都是str型 user = config.get_config_str('DATABASE', 'user') password = config.get_config_str('DATABASE', 'password') dbname = config.get_config_str('DATABASE', 'dbname') charset = config.get_config_str('DATABASE', 'charset') table = config.get_config_str('DATABASE', 'table') # # 获取数据库 # db = records.Database('mysql+pymysql://root:@localhost:3306/dev01_git') # db_url = 'mysql+pymysql://' + user + ':' + passwd + '@' + str(host) + ':' + str(port) + '/' + db db_url = 'mysql+pymysql://' + user + ':' + password + '@' + host + ':' + port + '/' + dbname + '?' + 'charset' + '=' + charset print(db_url) # connect = records.Database('mysql+pymysql://用户名:密码@sqlURl:sql端号/库名') # db = records.Database(db_url,connect_args={'charset' : 'utf8'}) db = records.Database(db_url) # 查询 # rows = db.query('select * from test_data where name = "李德涛";') sql1 = 'select * from ' + table + ';' # sql = 'select * from '+ table + ' where name = "李德涛";'
def setUp(self): # self.url1 = 'https://api.haitoutech.com/haitou-order/moneyFund/generateBuyOrder' self.logger.info('aaaadfdsafasdfsdaf') self.host = read_Config.ReadConfig().get_config('HOST', 'host')