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"
        }
    def test_ProjectAll(self, data):
        peojecttype = str(data["peojecttype"])
        case_describe = str(data["case_describe"])
        expected_code = int(data["expected_code"])

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

        customerid = readconfig.get_customer(peojecttype)
        url = readconfig.get_basedata('crm_url') + api.format(customerid)

        session = readconfig.get_basedata('member_session')
        requestid = str(uuid.uuid1())
        headers = {
            'Content-Type': "application/json",
            'Authorization': session,
            "x-requestid": requestid
        }
        r = requests.get(url=url, headers=headers)

        if r.status_code == 200:
            projectincustomerid = readdb.GetProjectInCustomerinfo(customerid)
            responeprojectincustomerid = []
            for i in range(len(r.json())):
                responeprojectincustomerid.append(r.json()[i]['id'])
                self.assertIn(r.json()[i]['id'].upper(), projectincustomerid,
                              case_describe + ",接口:{0}".format(api))
            self.assertEqual(len(responeprojectincustomerid),
                             len(projectincustomerid),
                             case_describe + ",接口:{0}".format(api))
        else:
            self.assertEqual(r.status_code, 200,
                             case_describe + ",接口:{0}".format(api))
예제 #3
0
    def test_Blog(self):
        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
        }
        r = requests.get(url=url, headers=headers)
        if r.status_code == 200:
            self.assertIn('id', r.json(), case_describe)
            customerinfo = readdb.GetBlog(readconfig.get_member('phone'))
            self.assertEqual(r.json()['id'], customerinfo['blogid'],
                             case_describe)
            self.assertEqual(r.json()['phone'], customerinfo['phone'],
                             case_describe)
            self.assertEqual(r.json()['companyName'],
                             customerinfo['companyName'], case_describe)
            self.assertEqual(r.json()['nickname'], customerinfo['nickname'],
                             case_describe)
            readconfig.set_member('blogid', customerinfo['blogid'])
        else:
            self.assertEqual(200, r.status_code, case_describe)
예제 #4
0
    def test_ContactUpdateLabels(self,data):
        labels = list(map(int,str(data["labels"]).split(',')))
        case_describe = str(data["case_describe"])
        expected_code = int(data["expected_code"])

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

        contactid = readconfig.get_contact('contact'+str(data["case_id"]))
        url = readconfig.get_basedata('crm_url')+api.format(contactid)
        session =  readconfig.get_basedata('member_session')
        requestid = str(uuid.uuid1())
        headers = {'Content-Type': "application/json",'Authorization':session,"x-requestid":requestid}
        payload ={
            "labels":labels
        }
        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 == expected_code:
            contactdetails = readdb.GetContactDetailsinfo(contactid)
            for i in range(len(contactdetails['labels'])):
                self.assertIn(contactdetails['labels'][i],labels,case_describe + ",接口:{0}".format(api))
            self.assertEqual(len(contactdetails['labels']),len(labels),case_describe + ",接口:{0}".format(api))
        else:
            self.assertEqual(r.status_code,expected_code,case_describe + ",接口:{0}".format(api))   
    def test_ClientOne(self):
        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
        }
        r = requests.get(url=url, headers=headers)
        if r.status_code == 200:
            clientinfo = readdb.GetClientinfo(
                readconfig.get_client('clientid1'))
            self.assertEqual(r.json()[0]['display'], clientinfo['display'],
                             case_describe)
            self.assertEqual(r.json()[0]['level'], clientinfo['level'],
                             case_describe)
            self.assertEqual(r.json()[0]['status'], clientinfo['status'],
                             case_describe)

        else:
            self.assertEqual(r.status_code, 200, case_describe)
    def test_ProjectUpdateName(self,data):
        projectname = str(data["projectname"])
        department = str(data["department"])
        case_describe = str(data["case_describe"])
        expected_code = int(data["expected_code"])

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

        if department == 'investment':
            projectid = readconfig.get_project('projectinvestmentid')
        elif department == 'factoring':
            projectid = readconfig.get_project('projectfactoringid')

        url = readconfig.get_basedata('crm_url')+api.format(projectid)
        session =  readconfig.get_basedata('member_session')
        requestid = str(uuid.uuid1())
        headers = {'Content-Type': "application/json",'Authorization':session,"x-requestid":requestid}
        payload ={
            "projectName":projectname
        }
        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==expected_code:
            projectdetails = readdb.GetProjectDetailsinfo(projectid)
            self.assertEqual(projectdetails['projectname'],projectname,case_describe + ",接口:{0}".format(api))
        else:
            self.assertEqual(r.status_code,expected_code,case_describe + ",接口:{0}".format(api))   
    def test_CustomerProperty(self):
        readconfig=ReadConfig.ReadConfig()
        readdb = ReadDB.Pyodbc()

        url = readconfig.get_basedata('crm_url')+api2
        session =  readconfig.get_basedata('member_session')
        headers = {'Content-Type': "application/json",'Authorization':session}
        r = requests.get(url=url, headers = headers)
        if r.status_code==200:
            customerpropertylabel = readdb.PropertyLabel(readconfig.get_labelmodule('customermodule'))
            for i in range(len(r.json()['customerLabel'])):
                for ii in range(len(customerpropertylabel)):
                    if r.json()['customerLabel'][i]['id'] == customerpropertylabel[ii]['id']:
                        self.assertEqual(r.json()['customerLabel'][i]['groupName'],customerpropertylabel[ii]['groupname'],case_describe + ",接口:{0}".format(api))
                        self.assertEqual(r.json()['customerLabel'][i]['departmentId'],customerpropertylabel[ii]['departmentid'],case_describe + ",接口:{0}".format(api))
                        # self.assertEqual(r.json()['customerLabel'][i]['functionModule'],contactpropertylabel[ii]['functionmodule'],case_describe + ",接口:{0}".format(api))
                        self.assertEqual(r.json()['customerLabel'][i]['isMultiple'],customerpropertylabel[ii]['ismultiple'],case_describe + ",接口:{0}".format(api))
                        self.assertEqual(r.json()['customerLabel'][i]['backgroundColor'],customerpropertylabel[ii]['backgroundcolor'],case_describe + ",接口:{0}".format(api))
                        self.assertEqual(r.json()['customerLabel'][i]['foregroundColor'],customerpropertylabel[ii]['foregroundcolor'],case_describe + ",接口:{0}".format(api))

                        for iii in range(len(r.json()['customerLabel'][i]['labels'])):
                            for iiii in range(len(customerpropertylabel[ii]['labels'])):
                                if r.json()['customerLabel'][i]['labels'][iii]['id'] == customerpropertylabel[ii]['labels'][iiii]['id']:
                                    self.assertEqual(r.json()['customerLabel'][i]['labels'][iii]['name'],r.json()['customerLabel'][i]['labels'][iii]['name'],case_describe + ",接口:{0}".format(api))
                                    self.assertEqual(len(r.json()['customerLabel'][i]['labels']),len(customerpropertylabel[ii]['labels']),case_describe + ",接口:{0}".format(api))

            myDepartments =  readdb.GetMyDepartments(readconfig.get_basedata('employeeid'))
            for a in range(len(r.json()['myDepartments'])):
                for aa in range(len(myDepartments)):
                    if r.json()['myDepartments'][a]['id'] == myDepartments[aa]['id']:
                        self.assertEqual(r.json()['myDepartments'][a]['name'],myDepartments[aa]['name'],case_describe + ",接口:{0}".format(api))
                        self.assertEqual(r.json()['myDepartments'][a]['queryLabelDepartmentId'],myDepartments[aa]['querylabeldepartmentid'],case_describe + ",接口:{0}".format(api))
            self.assertEqual(len(r.json()['myDepartments']),len(myDepartments),case_describe + ",接口:{0}".format(api))
        else:
            self.assertEqual(r.status_code,200,case_describe + ",接口:{0}".format(api))
    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
        }
        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:
            customerdetails = readdb.GetCustomerDetailsinfo(correlationid)
            self.assertEqual(int(customerdetails['customerTypeId']),Type,case_describe + ",接口:{0}".format(api))
        else:
            self.assertEqual(r.status_code,200,case_describe + ",接口:{0}".format(api))   
    def test_CustomerDetails(self, data):
        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')
        headers = {
            'Content-Type': "application/json",
            'Authorization': session
        }
        r = requests.get(url=url, 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:
            customerdetails = readdb.GetCustomerDetailsinfo(correlationid)
            self.assertEqual(customerdetails['name'],
                             r.json()['name'],
                             case_describe + ",接口:{0}".format(api))
            self.assertEqual(customerdetails['shortName'],
                             r.json()['shortName'],
                             case_describe + ",接口:{0}".format(api))
            self.assertEqual(customerdetails['city'],
                             r.json()['city'],
                             case_describe + ",接口:{0}".format(api))
            self.assertEqual(customerdetails['state'],
                             r.json()['state'],
                             case_describe + ",接口:{0}".format(api))
            self.assertEqual(int(customerdetails['customerProspectId']),
                             r.json()['customerProspectId'],
                             case_describe + ",接口:{0}".format(api))
            self.assertEqual(int(customerdetails['customerTypeId']),
                             r.json()['customerTypeId'],
                             case_describe + ",接口:{0}".format(api))
            self.assertEqual(int(customerdetails['customerKind']),
                             r.json()['customerKind'],
                             case_describe + ",接口:{0}".format(api))
        else:
            self.assertEqual(r.status_code, 200,
                             case_describe + ",接口:{0}".format(api))
    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"])
    def test_ProjectDetail(self,data):
        peojecttype = str(data["peojecttype"])
        case_describe = str(data["case_describe"])
        expected_code = int(data["expected_code"])

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

        projectid = readconfig.get_project(peojecttype)

        url = readconfig.get_basedata('crm_url')+api.format(projectid)
        session =  readconfig.get_basedata('member_session')
        requestid = str(uuid.uuid1())
        headers = {'Content-Type': "application/json",'Authorization':session,"x-requestid":requestid}
        r = requests.get(url=url,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:
            projectinfo = readdb.GetProjectDetailsinfo(projectid)

            if peojecttype =='projectinvestmentid':
                self.assertEqual(projectinfo['projectname'],r.json()['projectName'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['departmentid'],r.json()['departmentId'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(int(projectinfo['amount']),int(r.json()['investment']['amount']),case_describe + ",接口:{0}".format(api))
                self.assertEqual(int(projectinfo['estimate']),int(r.json()['investment']['estimate']),case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['conditions'],r.json()['investment']['conditions'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['commitment'],r.json()['investment']['commitment'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['newsituation'],r.json()['investment']['newSituation'],case_describe + ",接口:{0}".format(api))
                readconfig.set_project('projectinvestmentid',requestid)
            elif peojecttype =='projectfactoringid':
                self.assertEqual(projectinfo['projectname'],r.json()['projectName'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['departmentid'],r.json()['departmentId'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['sellername'],r.json()['factoring']['sellerName'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['buyername'],r.json()['factoring']['buyerName'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['businesstarget'],r.json()['factoring']['businessTarget'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['businesstype'],r.json()['factoring']['businessType'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['guarantee'],r.json()['factoring']['guarantee'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['quota'],r.json()['factoring']['quota'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(projectinfo['period'],r.json()['factoring']['period'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(int(projectinfo['interestrate1']),r.json()['factoring']['interestRate1'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(int(projectinfo['interestrate2']),r.json()['factoring']['interestRate2'],case_describe + ",接口:{0}".format(api))
                self.assertEqual(int(projectinfo['interestrate3']),r.json()['factoring']['interestRate3'],case_describe + ",接口:{0}".format(api))
                readconfig.set_project('projectfactoringid',requestid)
        self.assertEqual(r.status_code,expected_code,case_describe + ",接口:{0}".format(api)) 
예제 #12
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"])
예제 #13
0
    def test_CustomerSubordinate(self):
        readconfig=ReadConfig.ReadConfig()
        readdb = ReadDB.Pyodbc()

        url = readconfig.get_basedata('crm_url')+api
        session =  readconfig.get_basedata('member_session')
        headers = {'Content-Type': "application/json",'Authorization':session}
        r = requests.get(url=url, headers = headers)
        if r.status_code==200:
            customersubordinateid = readdb.GetCustomerSubordinateinfo(readconfig.get_basedata('employeeid'))
            responecustomersubordinateid = []
            for i in range(len(r.json()['list'])):
                responecustomersubordinateid.append(r.json()['list'][i]['id'])
                self.assertIn(r.json()['list'][i]['id'].upper(),customersubordinateid,case_describe + ",接口:{0}".format(api))
            self.assertEqual(len(responecustomersubordinateid),len(customersubordinateid),case_describe + ",接口:{0}".format(api))
            self.assertEqual(r.json()['count'],len(customersubordinateid),case_describe + ",接口:{0}".format(api))
        else:
            self.assertEqual(r.status_code,200,case_describe + ",接口:{0}".format(api))   
예제 #14
0
    def test_CustomerAll(self, data):
        key = str(data["key"])
        departmentId = str(data["departmentId"])
        case_describe = str(data["case_describe"])

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

        url = readconfig.get_basedata('crm_url') + api.format(
            key, departmentId)
        session = readconfig.get_basedata('member_session')
        headers = {
            'Content-Type': "application/json",
            'Authorization': session
        }
        r = requests.get(url=url, 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:
            customerindepartmentid = readdb.GetCustomerInDepartmentinfo(
                key, departmentId)
            responecustomerindepartmentid = []
            for i in range(len(r.json()['list'])):
                responecustomerindepartmentid.append(r.json()['list'][i]['id'])
                self.assertIn(r.json()['list'][i]['id'].upper(),
                              customerindepartmentid,
                              case_describe + ",接口:{0}".format(api))
            self.assertEqual(len(responecustomerindepartmentid),
                             len(customerindepartmentid),
                             case_describe + ",接口:{0}".format(api))
            self.assertEqual(r.json()['count'], len(customerindepartmentid),
                             case_describe + ",接口:{0}".format(api))
        else:
            self.assertEqual(r.status_code, 200,
                             case_describe + ",接口:{0}".format(api))
예제 #15
0
    def test_ClientMaintainNumber(self):
        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
        }
        r = requests.get(url=url, headers=headers)
        if r.status_code == 200 or r.status_code == 204:
            maintainnumber = readdb.GetClientMaintainNumber(
                readconfig.get_member('customerid'))
            self.assertEqual(r.json()['maintainNumber'], maintainnumber,
                             case_describe)
        else:
            self.assertEqual(r.status_code, 200, case_describe)
예제 #16
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"])
    def test_ContactUpdateBirthday(self, data):
        birthday = data["birthday"]
        case_describe = str(data["case_describe"])
        expected_code = int(data["expected_code"])

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

        contactid = readconfig.get_contact('contact1')
        url = readconfig.get_basedata('crm_url') + api.format(contactid)
        session = readconfig.get_basedata('member_session')
        requestid = str(uuid.uuid1())
        headers = {
            'Content-Type': "application/json",
            'Authorization': session,
            "x-requestid": requestid
        }
        payload = {"birthday": birthday}
        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 == expected_code:
            contactdetails = readdb.GetContactDetailsinfo(contactid)
            self.assertEqual(contactdetails['birthday'].strftime('%Y-%m-%d'),
                             birthday, case_describe + ",接口:{0}".format(api))
        else:
            self.assertEqual(r.status_code, expected_code,
                             case_describe + ",接口:{0}".format(api))
    def test_ClientAll(self):
        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
        }
        r = requests.get(url=url, headers=headers)
        if r.status_code == 200:
            clientallid = readdb.GetClientAllinfo(
                readconfig.get_member('customerid'))
            responeclientallid = []
            for i in range(len(r.json())):
                responeclientallid.append(r.json()[i]['id'])
                self.assertIn(r.json()[i]['id'], clientallid, case_describe)
            self.assertEqual(len(responeclientallid), len(clientallid),
                             case_describe)
        else:
            self.assertEqual(r.status_code, 200, case_describe)
예제 #19
0
 def setUpClass(self):
     self.readdb = ReadDB.Pyodbc()
     self.readconfig = ReadConfig.ReadConfig()
예제 #20
0
    def setUpClass(self):
        self.readdb = ReadDB.Pyodbc()
        self.readconfig = ReadConfig.ReadConfig()

        self.readdb.DBDelete("[AppVersionOpenRecord]")
        self.readdb.DBDelete("[AppVersion]")
    def setUpClass(self):
        self.readdb = ReadDB.Pyodbc()
        self.readconfig=ReadConfig.ReadConfig()

        self.readdb.DBDelete("[ContactLabel]")
        self.readdb.DBDelete("[Contact]")
예제 #22
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'])