WebEmailSend.py
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/8/13 下午3:55
# @Author : 付孟奇
import unittest, requests
from config.vendorHost import vendor_host
from config import vendorList
from util.generate import getTestCase
from util.log import logger
from util.HandleJenkins import config
from util.HandleJson import file_readAPI, file_read_global
class WebEmailSend(unittest.TestCase):
def testFunc(self):
'''发送验证码'''
data_list = getTestCase('WEB_api_case.xlsx', '发送验证码')
for i in range(len(data_list)):
self.getTest(data_list[i])
def getTest(self, data):
tcname = data['tc_name']
code = int(data['code'])
bizType = data['bizType']
toEmail = file_read_global('account', 'web_email')
api_type = 'sys'
logger.info('********************【' + tcname + '】接口测试开始!' + '********************')
headers = {
'Content-Type': 'application/json'
}
if config['pro'] in vendorList.web_login_forget_pwd:
payload = {
"bizType": bizType,
"toEmail": toEmail
}
logger.info('【' + tcname + '】的接口入参为:' + str(payload))
url = vendor_host + api_type + file_readAPI(api_type, 'sendValidCodeEmailUsingPOST')
response = requests.request('POST', url, headers=headers, json=payload)
if response.status_code is 200:
res = response.json()
self.assertEqual(res['code'], code, msg=str(res))
logger.info('【' + tcname + '】的接口返回参数为:' + str(res))
else:
logger.info(response.text)