WebQualityAuditProportionConfigRuleModify.py
2.64 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/8/13 下午3:55
# @Author : 付孟奇
import unittest, requests
from config.vendorHost import vendor_host
from util.generate import getTestCase
from util.log import logger
from util.HandleJson import file_readAPI
from util.HandleJson import file_read_global, file_updata_global
from util.HandleSql import db_sql
class WebQualityAuditProportionConfigRuleModify(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'])
proportion = int(data['proportion'])
ruleName = file_read_global('proportion', 'role_name')
channle = file_read_global('channel', 'channel_name')
age_id = file_read_global('age', '60岁以下')
age = db_sql.select_age_value(age_id)
productType = file_read_global('product', 'productTypeId')
branchId = file_read_global('organization', 'branchId')
subBranchId = file_read_global('organization', 'subBranchId')
role_id = file_read_global('proportion', 'role_id')
api_type = 'qa'
logger.info('********************【' + tcname + '】接口测试开始!' + '********************')
headers = {
'Content-Type': 'application/json',
'X-Auth-Token': file_read_global('web_login', 'token')
}
payload = {
"id": role_id,
"ruleName": ruleName,
"proportion": proportion,
"checkedChannelArr": [channle],
"checkedAgeArr": [age],
"checkedProductTypeArr": [productType],
"ai": [],
"checkedProvinceArr": [branchId],
"checkedCityArr": [subBranchId],
"checkedPeriodArr": [],
"checkedSystemTypeArr": [],
"checkedOrderTypeArr": [],
"samplingPeriod": "0",
}
logger.info('【' + tcname + '】的接口入参为:' + str(payload))
url = vendor_host + api_type + file_readAPI(api_type, 'modifyProportionRuleUsingPOST')
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))
file_updata_global('proportion', 'role_name', ruleName)
logger.info('【' + tcname + '】的接口返回参数为:' + str(res))
else:
logger.info(response.text)