コード例 #1
0
    def test_ScheduleAdd(self, data):
        customertype = str(data['customertype'])
        time = int(data["time"])
        summary = str(data['summary']) + str(data['case_id'])
        minutes = str(data['minutes'])
        cc = str(data['cc'])
        expected_code = int(data["expected_code"])
        case_describe = str(data["case_describe"])

        excel = ReadExcl.Xlrd()
        readconfig = ReadConfig.ReadConfig()
        readdb = ReadDB.Pyodbc()

        customerid = readconfig.get_customer(customertype)

        url = readconfig.get_basedata('crm_url') + api
        session = readconfig.get_basedata('member_session')
        requestid = str(uuid.uuid1())
        headers = {
            'Content-Type': "application/json",
            'Authorization': session,
            "x-requestid": requestid
        }
        payload = {
            "beginTime": "2018-12-28 02:13:06.178",
            "endTime": "2018-12-28 02:13:06.178",
            "summary": "string",
            "minutes": 0,
            "cc": "string",
            "customerId": "string"
        }
コード例 #2
0
 def test_Token(self, data):
     excel = ReadExcl.Xlrd()
     readconfig = ReadConfig.ReadConfig()
     #填写求求参数
     url = readconfig.get_url('url') + api
     payload = {
         "grant_type": str(data["grant_type"]),
         "phone": str(data["phone"]),
         "code": str(data["code"])
     }
     r = requests.post(url=url, data=payload)
     #处理请求数据到excl用例文件
     excel.set_cell(sheet_name, int(data["case_id"]),
                    excel.get_sheet_colname(sheet_name)["result_code"],
                    r.status_code, excel.set_color(r.status_code))
     excel.set_cell(sheet_name, int(data["case_id"]),
                    excel.get_sheet_colname(sheet_name)["result_msg"],
                    r.text, excel.set_color())
     excel.save()
     #存储数据到本地config数据文件
     if r.status_code == 200 or r.status_code == 204:
         session = r.json()["token_type"] + " " + r.json()["access_token"]
         readconfig.set_member('session', session)
         readconfig.save()
     self.assertEqual(r.status_code, data['expected_code'],
                      data["case_describe"])
コード例 #3
0
    def test_CodeSend(self, data):
        excel = ReadExcl.Xlrd()
        readconfig = ReadConfig.ReadConfig()

        #填写求求参数h
        url = readconfig.get_url('url') + api
        payload = {
            "Phone": str(data["phone"]),
            "CodeType": int(data["type"]),
            "Domain": 'sss'
        }
        headers = {"Content-Type": "application/json"}
        r = requests.post(url=url, data=json.dumps(payload), headers=headers)
        #处理请求数据到excl用例文件
        excel.set_cell(sheet_name, int(data["case_id"]),
                       excel.get_sheet_colname(sheet_name)["result_code"],
                       r.status_code, excel.set_color(r.status_code))
        excel.set_cell(sheet_name, int(data["case_id"]),
                       excel.get_sheet_colname(sheet_name)["result_msg"],
                       r.text, excel.set_color())
        excel.save()

        #存储数据到本地config数据文件
        if r.status_code == 200 or r.status_code == 204:
            readconfig.set_member('phone', str(data['phone']))
            readconfig.save()
        self.assertEqual(r.status_code, data['expected_code'],
                         data["case_describe"])
コード例 #4
0
    def test_ClientAdd(self, data):
        excel = ReadExcl.Xlrd()
        readconfig = ReadConfig.ReadConfig()
        readdb = ReadDB.Pymssql()

        #填写求求参数
        url = readconfig.get_url('url') + api
        session = readconfig.get_member('session')
        origin = readconfig.get_url('origin')
        headers = {
            'Content-Type': "application/json",
            'Authorization': session,
            "Origin": origin
        }
        payload = {
            "display": str(data["display"]),
            "phone": str(data["phone"]),
            "level": str(data["level"])
        }
        r = requests.post(url=url, headers=headers, data=json.dumps(payload))

        #处理请求数据到excl用例文件
        excel.set_cell(sheet_name, int(data["case_id"]),
                       excel.get_sheet_colname(sheet_name)["result_code"],
                       r.status_code, excel.set_color(r.status_code))
        excel.set_cell(sheet_name, int(data["case_id"]),
                       excel.get_sheet_colname(sheet_name)["result_msg"],
                       r.text, excel.set_color())
        excel.save()

        if r.status_code == 200 or r.status_code == 204:
            self.assertIn('id', r.json(), data["case_describe"])
            clientinfo = readdb.GetClientinfo(r.json()['id'])
            self.assertEqual(clientinfo['display'], str(data["display"]),
                             data["case_describe"])
            self.assertEqual(clientinfo['level'], data['level'],
                             data["case_describe"])
            self.assertEqual(clientinfo['phone'], str(data["phone"]),
                             data["case_describe"])
            self.assertEqual(clientinfo['companyId'],
                             readconfig.get_member('companyId'),
                             data["case_describe"])
            self.assertEqual(clientinfo['customerId'],
                             readconfig.get_member('customerId'),
                             data["case_describe"])

            readconfig.set_client('clientid' + str(data['level']),
                                  r.json()['id'])

        self.assertEqual(r.status_code, data['expected_code'],
                         data["case_describe"])
コード例 #5
0
    def test_CodeVerify(self, data):
        readconfig=ReadConfig.ReadConfig()
        excel = ReadExcl.Xlrd()

        #填写求求参数
        url = readconfig.get_url('url')+api
        payload = {"phone":str(data["phone"]),"codeType":int(data["type"]),"code":str(data["code"])}
        r = requests.get(url=url,params = payload)

        # 处理请求数据到excl用例文件
        excel.set_cell(sheet_name,int(data["case_id"]),excel.get_sheet_colname(sheet_name)["result_code"],r.status_code,excel.set_color(r.status_code))
        excel.set_cell(sheet_name,int(data["case_id"]),excel.get_sheet_colname(sheet_name)["result_msg"],r.text,excel.set_color(r.status_code))
        excel.save()
        
        self.assertEqual(r.status_code,data['expected_code'],data["case_describe"])
コード例 #6
0
    def test_ClientMaintain(self, data):
        readdb = ReadDB.Pymssql()
        excel = ReadExcl.Xlrd()
        readconfig = ReadConfig.ReadConfig()
        #填写求求参数
        url = readconfig.get_url('url') + api
        session = readconfig.get_member('session')
        origin = readconfig.get_url('origin')
        headers = {
            'Content-Type': "application/json",
            'Authorization': session,
            "Origin": origin
        }
        readdb.SetCustomerMoney(str(data["money"]),
                                readconfig.get_member('userid'))
        if data['isone']:
            payload = [{
                "id": readconfig.get_client('clientid2'),
                "display": "qqq"
            }]
        else:
            payload = [{
                "id": readconfig.get_client('clientid3'),
                "display": "qqq"
            }, {
                "id": readconfig.get_client('clientid4'),
                "display": "qqq"
            }]
        r = requests.post(url=url, headers=headers, data=json.dumps(payload))

        #处理请求数据到excl用例文件
        excel.set_cell(sheet_name, int(data["case_id"]),
                       excel.get_sheet_colname(sheet_name)["result_code"],
                       r.status_code, excel.set_color(r.status_code))
        excel.set_cell(sheet_name, int(data["case_id"]),
                       excel.get_sheet_colname(sheet_name)["result_msg"],
                       r.text, excel.set_color())
        excel.save()

        if r.status_code == 200 or r.status_code == 204:
            orderprice = readdb.GetClientMaintainOrder(r.json()['orderId'])
            usermoney = readdb.GetUserMoney(readconfig.get_member('userid'))
            self.assertEqual(orderprice, usermoney, data["case_describe"])
        self.assertEqual(r.status_code, data['expected_code'],
                         data["case_describe"])
コード例 #7
0
    def test_ContactUpdateEmail(self, data):
        email = str(data["email"])
        case_describe = str(data["case_describe"])
        expected_code = int(data["expected_code"])

        excel = ReadExcl.Xlrd()

        contactids = list(
            map(str,
                str(self.readconfig.get_dynamicdata("contact_id")).split(',')))
        contactid = int(random.sample(contactids, 1)[0])

        url = self.readconfig.get_basedata('crm_url') + api.format(contactid)
        session = self.readconfig.get_basedata('member_session')
        requestid = str(uuid.uuid1())
        headers = {
            'Content-Type': "application/json",
            'Authorization': session,
            "x-requestid": requestid
        }
        payload = {"email": email}
        r = requests.post(url=url, data=json.dumps(payload), headers=headers)

        #处理请求数据到excl用例文件
        excel.set_cell(sheet_name, int(data["case_id"]),
                       excel.get_sheet_colname(sheet_name)["result_code"],
                       r.status_code, excel.set_color(r.status_code))
        excel.set_cell(sheet_name, int(data["case_id"]),
                       excel.get_sheet_colname(sheet_name)["result_msg"],
                       r.text, excel.set_color())
        excel.save()

        #数据对比
        if r.status_code == 200:
            contactdetails = self.readdb.GetContactDetailsinfo(contactid)
            self.assertEqual(contactdetails['email'], email,
                             case_describe + ",接口:{0}".format(api))
        self.assertEqual(r.status_code, expected_code,
                         case_describe + ",接口:{0}".format(api))
コード例 #8
0
    def test_ClientRemarks(self, data):
        excel = ReadExcl.Xlrd()
        readconfig=ReadConfig.ReadConfig()
        readdb = ReadDB.Pymssql()
        
        #填写求求参数
        url = readconfig.get_url('url')+api.format(readconfig.get_client('clientid1'))
        session =  readconfig.get_member('session')
        origin = readconfig.get_url('origin')
        headers = {'Content-Type': "application/json",'Authorization':session,"Origin":origin}
        payload = {"remarks": str(data["remarks"])}
        r = requests.post(url=url, headers = headers,data = json.dumps(payload))

        #处理请求数据到excl用例文件
        excel.set_cell(sheet_name,int(data["case_id"]),excel.get_sheet_colname(sheet_name)["result_code"],r.status_code,excel.set_color(r.status_code))
        excel.set_cell(sheet_name,int(data["case_id"]),excel.get_sheet_colname(sheet_name)["result_msg"],r.text,excel.set_color())
        excel.save()
        
        if r.status_code==200 or r.status_code==204: 
            clientinfo = readdb.GetClientinfo(readconfig.get_client('clientid1'))
            self.assertEqual(clientinfo['remarks'],str(data['remarks']),data["case_describe"])
        self.assertEqual(r.status_code,data['expected_code'],data["case_describe"])
コード例 #9
0
import unittest
import ddt
from common import ReadExcl,ReadDB
import ReadConfig 
import requests
import json 
import uuid

api='api/Customer/{0}/Type'
sheet_name = "CustomerUpdateType"

excel = ReadExcl.Xlrd()

@ddt.ddt
class CustomerUpdateType(unittest.TestCase): 
    @ddt.data(*excel.get_xls_next(sheet_name))
    def test_CustomerUpdateType(self,data):
        Type = int(data["type"])
        customertab = str(data["customertab"])
        case_describe = str(data["case_describe"])

        readconfig=ReadConfig.ReadConfig()
        readdb = ReadDB.Pyodbc()

        correlationid = readconfig.get_customer(customertab)
        url = readconfig.get_basedata('crm_url')+api.format(correlationid)
        session =  readconfig.get_basedata('member_session')
        requestid = str(uuid.uuid1())
        headers = {'Content-Type': "application/json",'Authorization':session,"x-requestid":requestid}
        payload ={
            "customerTypeId":Type
コード例 #10
0
    def test_CustomerCreate(self, data):
        name = str(data["name"])+str(data["case_id"])
        synopsis = str(data["synopsis"])
        shortName = str(data["shortName"])
        city = str(data["city"])
        state = str(data["state"])
        customerKind = int(data["customerKind"])
        departtype = int(data["departtype"])
        labels = list(map(int,str(data["labels"]).split(',')))
        case_describe = str(data["case_describe"])

        excel = ReadExcl.Xlrd()
        readconfig=ReadConfig.ReadConfig()
        readdb = ReadDB.Pyodbc()
        
        #填写求求参数h
        url = readconfig.get_basedata('crm_url')+api
        session =  readconfig.get_basedata('member_session')
        requestid = str(uuid.uuid1())
        headers = {'Content-Type': "application/json",'Authorization':session,"x-requestid":requestid}

        if data["shortName"] != '':
            shortName = shortName+str(data["case_id"])
        if data["synopsis"] != '':
            synopsis = synopsis+str(data["case_id"])

        if departtype == 1:
            departid = readconfig.get_basedata('investmentdepartmentId')
            idtype = 'investmentcustomerid'
        elif departtype ==2:
            departid = readconfig.get_basedata('factoringdepartmentid')
            idtype = idtype = 'actoringdecustomerid'
        payload ={
            "name": name,
            "shortName": shortName,
            "city": city,
            "state": state,
            "synopsis":synopsis,    
            "customerKind":customerKind,
            "labelIds":labels,
            "departmentId":departid
            }

        r = requests.post(url=url,data = json.dumps(payload),headers = headers)

        #处理请求数据到excl用例文件
        excel.set_cell(sheet_name,int(data["case_id"]),excel.get_sheet_colname(sheet_name)["result_code"],r.status_code,excel.set_color(r.status_code))
        excel.set_cell(sheet_name,int(data["case_id"]),excel.get_sheet_colname(sheet_name)["result_msg"],r.text,excel.set_color())
        excel.save()
        
        #数据对比
        if r.status_code==200 or r.status_code ==204:
            customerinfo = readdb.GetCustomer(name)
            customerlabelsid = readdb.GetCustomerLabelsinfo(customerinfo['correlationId'])
            self.assertEqual(customerinfo['name'],name,case_describe + ",接口:{0}".format(api))
            self.assertEqual(customerinfo['shortName'],shortName,case_describe + ",接口:{0}".format(api))
            self.assertEqual(customerinfo['city'],city,case_describe + ",接口:{0}".format(api))
            self.assertEqual(customerinfo['state'],state,case_describe + ",接口:{0}".format(api))
            self.assertEqual(customerinfo['customerKind'],str(customerKind),case_describe + ",接口:{0}".format(api))
            for i in range(len(customerlabelsid)):
                self.assertIn(customerlabelsid[i],labels,case_describe + ",接口:{0}".format(api))
                self.assertEqual(len(customerlabelsid),len(labels),case_describe + ",接口:{0}".format(api))
        self.assertEqual(r.status_code,data['expected_code'],case_describe + ",接口:{0}".format(api))
        readconfig.set_customer(idtype,customerinfo['correlationId'])
コード例 #11
0
    def test_AppVersion(self, data):
        isnewversion = str(data["isnewversion"])
        isshow = int(data["isshow"])
        isread = int(data["isread"])
        status = str(data["status"])
        case_describe = str(data["case_describe"])
        expected_code = int(data["expected_code"])

        lastrowid = 0

        excel = ReadExcl.Xlrd()

        session = self.readconfig.get_basedata('member_session')
        headers = {
            'Content-Type': "application/json",
            'Authorization': session
        }

        if isnewversion != '':
            agentid = self.readconfig.get_basedata('dingding_agentid')
            lastrowid = int(self.readdb.AddVersion(agentid, isnewversion))

            self.readconfig.set_dynamicdata('app_versionid', str(lastrowid))

        if isshow == 1:
            self.readdb.UpdateVersion()

        if isread == 1:
            versionid = self.readconfig.get_dynamicdata('app_versionid')
            url = self.readconfig.get_basedata('crm_url') + apiread.format(
                versionid)
            r = requests.post(url=url, headers=headers)

            excel.set_cell(sheet_name, int(data["case_id"]),
                           excel.get_sheet_colname(sheet_name)["result_code"],
                           r.status_code, excel.set_color(r.status_code))
            excel.set_cell(sheet_name, int(data["case_id"]),
                           excel.get_sheet_colname(sheet_name)["result_msg"],
                           r.text, excel.set_color())
            excel.save()

            if r.status_code == 200:
                openrecord = self.readdb.GetAppVersionOpenRecord(
                    self.readconfig.get_basedata('employee_id'))
                self.assertEqual(self.readconfig.get_basedata('employee_id'),
                                 openrecord[0], "版本打开记录版本号未对上,接口:" + apiread)
                self.assertEqual(str(versionid), str(openrecord[1]),
                                 "版本打开记录版本号未对上,接口:" + apiread)
            self.assertEqual(r.status_code, data['expected_code'],
                             "版本打开记录版本号未对上,接口:" + apiread)

        url = self.readconfig.get_basedata('crm_url') + apiversion
        r = requests.get(url=url, headers=headers)

        excel.set_cell(sheet_name, int(data["case_id"]),
                       excel.get_sheet_colname(sheet_name)["result_code"],
                       r.status_code, excel.set_color(r.status_code))
        excel.set_cell(sheet_name, int(data["case_id"]),
                       excel.get_sheet_colname(sheet_name)["result_msg"],
                       r.text, excel.set_color())
        excel.save()

        if r.status_code == 200:
            self.assertEqual(str(r.json()['status']), status,
                             case_describe + ",接口:{0}".format(apiversion))
        self.assertEqual(r.status_code, data['expected_code'],
                         case_describe + ",接口:{0}".format(apiversion))