WebQualityAuditSubmit.py 3.05 KB
#!/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.vendorPath import global_path
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


class WebQualityAuditSubmit(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'])
        manualConclusion = data['manualConclusion']
        orderSource = int(data['orderSource'])
        orderRecordId = file_read_global('order', 'orderRecordId')
        submitRecordId = file_read_global('order', 'submitRecordId')
        phaseId = file_read_global('order', 'phaseId')
        phaseNum = file_read_global('order', 'phaseNum')
        hintId = file_read_global('order', 'hintId')
        hintNum = file_read_global('order', 'hintNum')

        api_type = 'qa'

        logger.info('********************【' + tcname + '】接口测试开始!' + '********************')

        headers = {
            'Content-Type': 'application/json',
            'X-Auth-Token': file_read_global('web_login', 'token')
        }
        payload = {
            "qualityAuditAdvice": 3,
            "orderRecordId": orderRecordId,
            "submitRecordId": submitRecordId,
            "submitDetailId": "",
            "auditResult": [
                {
                    "phaseId": phaseId,
                    "phaseNum": phaseNum,
                    "hint": [
                        {
                            "manualConclusion": manualConclusion,
                            "auditConclusion": [
                                {
                                    "label": "客户离席",
                                    "value": "0.1",
                                    "checked": 1
                                }
                            ],
                            "hintId": hintId,
                            "hintNum": hintNum
                        }
                    ]
                }
            ],
            "changed": 0,
            "remark": "",
            "orderSource": orderSource,
            "tag": "",
            "modifyTag": "",
            "comparisonResult": 2,
            "rerecord": ""
        }
        logger.info('【' + tcname + '】的接口入参为:' + str(payload))

        url = vendor_host + api_type + file_readAPI(api_type, 'submitAuditUsingPOST')
        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)