예제 #1
0
 def test_throw_sea_002(self):
     """开启丢公海原因时手动丢公海"""
     us = user.User()
     customer_id = self.cust.getCustomerID()
     reasons = self.cust.cus_reason().json()["data"]
     reason_id = reasons[0]["id"]
     reason_name = reasons[0]["name"]
     reason = {
         "id": reason_id,  # 丢公海原因
         "comment": "手动丢弃客户的原因" + str(random.randint(1, 1000))  # 原因说明
     }
     expect = reason_name + "(" + reason["comment"] + ")"
     result = self.cust.throw_sea(customer_id, reason)
     self.assertEqual(result.status_code, 200, msg=result.content)
     # 查看客户详情,判断客户是否是公海客户
     result_detail = self.cust.customer_detail(customer_id)
     self.assertStatus(result_detail)
     data = result_detail.json()["data"]
     # 断言客户为公海客户,丢公海类型、丢公海原因,丢公海人为登录人
     self.assertEqual(data["lock"], False,
                      msg=data["name"])  # lock=false公海客户,lock=true非公海客户
     self.assertEqual(data["recycleType"], 1,
                      msg=data["name"])  # 1手动丢公海,2自动丢公海
     self.assertEqual(data["recycleReason"], expect, msg=data["name"])
     self.assertEqual(data["recycleName"], us.getName(), msg=data["name"])
예제 #2
0
 def test_Get_Allusers(self):
     """测试获取组织架构接口:获取组织架构"""
     u = user.User()
     r = u.get_Organization()
     self.assertEqual(r.status_code, 200)
     if r.status_code == 200:
         organization = r.json()
         self.assertTrue(len(organization) > 0)  # 判断返回的组织架构中有数据
예제 #3
0
 def test_teamList_dept(self):
     """测试团队的客户列表:按人员查询:刘洋C"""
     us = user.User()
     param = {
         "field": "lastActAt",
         "order": "asc",
         "xpath": "",
         "pageSize": 20,
         "pageIndex": 1,
         "userId": us.get_UserId("刘洋C"),
         "tagsParams": [],
         "statusIds": [],
         "regional": {}
     }
     result = self.cust.customer_team(param)
     # 断言请求状态和错误码是否正确
     self.assertStatus(result)
     print('开发客户->团队客户的列表响应时间:', result.elapsed.microseconds / 1000, 'ms')
     data = result.json()["data"]
     total_records = data["totalRecords"]
     records = data["records"]  # list
     actual_total = len(records)  # 实际数据数量
     if total_records > 0:
         first_last_actat = records[0]["lastActAt"]
     # 断言数据为开发客户且按跟进时间顺序排序
     for cus in records:
         self.assertEqual(cus["customerType"], 1,
                          msg=cus["name"])  # 判断客户为开发客户
         self.assertEqual(cus["ownerName"], "刘洋C", msg=cus["name"])
         self.assertTrue(first_last_actat <= cus["lastActAt"],
                         msg=cus["name"])  # 判断列表按跟进时间倒叙排序
         first_last_actat = cus["lastActAt"]
     if total_records > param["pageSize"]:
         page = math.ceil(total_records / param["pageSize"])
         for p in range(2, page + 1):
             param["pageIndex"] = p
             page_result = self.cust.customer_team(param)
             self.assertStatus(page_result)
             page_records = page_result.json()["data"]["records"]
             actual_total += len(page_records)
             for cus in page_records:
                 self.assertEqual(cus["customerType"], 1,
                                  msg=cus["name"])  # 判断客户为开发客户
                 self.assertEqual(cus["ownerName"], "刘洋C", msg=cus["name"])
                 self.assertTrue(first_last_actat <= cus["lastActAt"],
                                 msg=cus["name"])  # 判断列表按跟进时间倒叙排序
                 first_last_actat = cus["lastActAt"]
     print("团队客户按人员查询结果数量", actual_total)
     # 断言返回的总数是否与实际数量相同
     self.assertEqual(total_records, actual_total)
예제 #4
0
 def test_UserProfile(self):
     """测试个人信息界面"""
     f = readConfig.ReadConfig()
     username = f.getUserValue('username')
     u = user.User()
     result = u.get_UserProfile()
     self.assertEqual(result.status_code, 200)
     if result.status_code == 200:
         json_response = result.json()
         self.assertEqual(json_response["errcode"], 0, msg='返回信息错误')
         self.assertEqual(json_response["errmsg"], "success", msg='返回信息错误')
         if json_response["errmsg"] == "success":
             username_response = json_response['data']["username"]
             self.assertEqual(username,
                              username_response,
                              msg='登录人与返回信息不一致')
             print('登录人userName:', username_response)
예제 #5
0
    def test_ownSalesleads(self):
        """测试我的线索列表用例:默认跟进时间顺序排序"""
        param = {
            "field": "lastActAt",
            "order": "desc",
            "pageSize": 20,
            "pageIndex": 1,
            "statusList": None,
            "tagsParams": []
        }
        sale = salesleads.Salesleades()
        result = sale.own_saleslead(param)
        u = user.User()
        login_name = u.getName()
        self.assertEqual(result.status_code, 200)

        json_response = result.json()
        self.assertEqual(json_response["errcode"], 0, msg='返回信息错误')
        self.assertEqual(json_response["errmsg"], "success", msg='返回信息错误')

        print('我的线索->我的线索列表响应时间:', result.elapsed.microseconds / 1000, 'ms')
        data = json_response["data"]
        totalRecords = data["totalRecords"]
        records = data["records"]  # list
        if totalRecords > param["pageSize"]:
            page = math.ceil(totalRecords / param["pageSize"])
            for p in range(2, page + 1):
                param["pageIndex"] = p
                pageResult = sale.own_saleslead(param)
                self.assertEqual(pageResult.status_code, 200, msg='翻页错误')
                json = pageResult.json()
                self.assertEqual(json["errmsg"], "success", msg='翻页错误')
                pagedata = json["data"]["records"]
                records.extend(pagedata)
        print("我的线索实际数据数量", len(records))
        self.assertEqual(totalRecords, len(records),
                         msg='返回总数与实际数量总数不同')  # 判断返回的数据总数与实际数据数量是否相同
        if totalRecords > 0:
            firstAt = records[0]["lastActAt"]
            for sa in records:
                self.assertTrue(firstAt >= sa["lastActAt"],
                                msg='跟进时间倒叙排序正确')  # 判断列表按跟进时间倒叙排序
                self.assertEqual(sa["responsorName"],
                                 login_name,
                                 msg=sa["name"])  # 判断列表数据负责人是不是登录人,若不是打印出错误的数据
                firstAt = sa["lastActAt"]
예제 #6
0
 def test_throw_sea_001(self):
     """未开启丢公海原因时手动丢公海"""
     us = user.User()
     customer_id = self.cust.getCustomerID()
     result = self.cust.throw_sea(customer_id)
     self.assertEqual(result.status_code, 200, msg=result.content)
     # 查看客户详情,判断客户是否是公海客户
     result_detail = self.cust.customer_detail(customer_id)
     self.assertStatus(result_detail)
     data = result_detail.json()["data"]
     # 断言客户为公海客户,丢公海类型、丢公海原因为空,丢公海人为登录人
     self.assertEqual(data["lock"], False,
                      msg=data["name"])  # lock=false公海客户,lock=true非公海客户
     self.assertEqual(data["recycleType"], 1,
                      msg=data["name"])  # 1手动丢公海,2自动丢公海
     self.assertEqual(data["recycleReason"], "", msg=data["name"])
     self.assertEqual(data["recycleName"], us.getName(), msg=data["name"])
예제 #7
0
 def setUpClass(cls):
     print("项目管理:start")
     # 获取登录人Id
     fp = readConfig.ReadConfig()
     cls.user_id = fp.getUserValue("userid")
     cls.pro = project.Project()
     cls.param = {
         "pageIndex": 1,
         "pageSize": 20,
         "keyword": "",
         "status": 1,  # 0 全部状态 1 进行中 2已完成
         "type": 2  # 0 全部类型 1 我参与的 2 我创建的 3 我负责的
     }
     # 获取我创建的最新一个项目id
     try:
         cls.project_id = cls.pro.my_list(
             cls.param).json()["data"]["records"][0]["id"]
     except Exception as e:
         print("获取项目id出错!", e)
     cls.us = user.User()
예제 #8
0
 def test_customer_owner(self):
     """转移客户"""
     customer_id = self.cust.getCustomerID()
     us = user.User().get_colleague()
     data = {
         "customerType": 1,
         "updateChance": True,  # 机会是否转移
         "ownerId": us["id"],
         "ownerName": us["name"],
         "updateFlowEvent": True,  # 快点是否转移
         "ids": customer_id
     }
     result = self.cust.owner_customer(data)
     self.assertStatus(result)
     # 调用客户详情接口,查看负责人是否修改成功
     result_detail = self.cust.customer_detail(customer_id)
     self.assertStatus(result_detail)
     # 客户详情查看负责人id和name是否与提交是数据一致
     owner = result_detail.json()["data"]["owner"]
     self.assertEqual(owner["name"], data["ownerName"], msg="转移后客户负责人显示错误")
     self.assertEqual(owner["id"], data["ownerId"], msg="转移后客户负责人显示错误")
예제 #9
0
    def test_Edit_Wreport(self):
        '''测试编辑报告用例:编辑报告内容'''
        reportType = 3
        # "报告类型,int,1:日报,2:周报,3:月报"
        if reportType == 1:
            T = get_Time_Type.getTimeRegionByType('Today')
            beginAt = T[0]
            endAt = T[1]
        elif reportType == 2:
            T = get_Time_Type.getTimeRegionByType('TheWeek')
            beginAt = T[0]
            endAt = T[1]
        elif reportType == 3:
            T = get_Time_Type.getTimeRegionByType('TheMonth')
            beginAt = T[0]
            endAt = T[1]
        us = user.User()
        reviewer = us.get_User('刘洋C')
        members = [us.get_User('布莱尔'), us.get_User('李明A')]
        wreport = workReport.WorkReport()
        wreportId = wreport.getID()
        wreport_request = {
            "activityStat": True,
            "crmDatas": wreport.get_CrmData(beginAt, endAt).json(),
            "content": "1、这里是编辑过得报告内容,2、呵呵",
            "projectId": "5a0ae0fd19b8207d13c71252",
            "reviewer": {
                "user": reviewer
            },
            "members": {
                "users": members
            },
        }

        result = wreport.edit_wreport(wreportId, wreport_request)
        print(result.json())
        self.assertEqual(result.status_code, 200)
        wreport_response = result.json()
        self.assertEqual(wreport_request['content'],
                         wreport_response['content'])  #判断报告内容是否语体教相同
예제 #10
0
 def test_OwnSaleslead_Search(self):
     """测试我的线索列表搜索线索姓名或公司名称,关键字:张瑞"""
     key = '线索'
     param = {
         "keyword": key,
         "pageSize": 20,
         "pageIndex": 1,
     }
     sale = salesleads.Salesleades()
     result = sale.own_saleslead(param)
     u = user.User()
     login_name = u.getName()
     self.assertEqual(result.status_code, 200)
     result_json = result.json()
     self.assertEqual(result_json["errcode"], 0)
     self.assertEqual(result_json["errmsg"], "success")
     records = result_json["data"]["records"]
     totalRecords = result_json["data"]["totalRecords"]
     if totalRecords > param["pageSize"]:
         page = math.ceil(totalRecords / param["pageSize"])
         for p in range(2, page + 1):
             param["pageIndex"] = p
             pageResult = sale.own_saleslead(param)
             self.assertEqual(pageResult.status_code, 200, msg='翻页错误')
             json = pageResult.json()
             self.assertEqual(json["errmsg"], "success", msg='翻页错误')
             pagedata = json["data"]["records"]
             records.extend(pagedata)
     if totalRecords == 0:
         self.assertEqual(records, None)
     else:
         print("搜索结果实际数据数量", len(records))
         self.assertEqual(totalRecords, len(records),
                          msg='返回总数与实际数量总数不同')  # 判断返回的数据总数与实际数据数量是否相同
     for sa in records:
         self.assertEqual(sa["responsorName"], login_name,
                          msg=sa["name"])  # 判断列表数据负责人是不是登录人,若不是打印出错误的数据
         isTrue = (key in sa["name"]) or (key in sa["companyName"])
         self.assertTrue(isTrue, msg='搜索结果错误!')
예제 #11
0
 def test_CreateBulletin(self):  # 实例方法
     """测试发布公告用例:填写所有字段 """
     U = user.User()
     attachment = attachments.attachments('19')
     data_request = {
         "attachmentUUId":
         attachment['UUId'],
         "title":
         "公告标题" +
         time.strftime('%Y-%m-%d %H:%M', time.localtime(time.time())),
         "content":
         "公告内容" + str(random.randint(1, 300)),
         "members": {
             "depts": [U.get_Dept('销售部')],
             "users": [U.get_User('陈老师')]
         },
         "attachments": [attachment]
     }
     B = bulletin.Bulletin()
     result = B.createBulletin(data_request)
     self.assertEqual(result.status_code, 200)
     data_response = result.json()
     self.assertEqual(data_request['title'], data_response['title'])
     self.assertEqual(data_request['content'], data_response['content'])
예제 #12
0
    def test_create_follow_001(self):
        """客户添加快速记录:填写所有系统字段"""
        u = user.User()
        customer_id = self.cust.get_similar_customer()["id"]
        fo = follow.Follow()
        type_id = fo.get_activity_type_id()  # 记录行为中任意一个行为的id
        print(type_id)
        cust_data = self.fo.new_activity(customer_id).json()["data"]
        data = {
            "uuid":
            attachments.attachments('0')['UUId'],
            "audioInfo": [{  # 录音文件
                "length":
                4,
                "fileName":
                "CEC338E0-D700-41FC-9A8C-8435477C3414/153197011674852.wav"
            }],
            "remindAt":
            int(datetime.now().timestamp() + 90000),  # 25小时以后
            "typeId":
            type_id,  # 记录行为ID
            "atUserIds": [u.get_UserId("陈老师")],  # @人员
            "contactPhone":
            "",  # 联系人电话
            "contactName":
            "",  # 联系人姓名
            "tags": [],  # 标签
            "customerId":
            customer_id,  # 客户ID
            "extUpdateAt":
            1512959975,
            "location": {  # 定位
                "loc": [30.689161, 104.0737],
                "addr": "成都龙腾越人力资源管理有限公司(今年万达甲级写字楼B座3101)"
            },
            "isEnableCus":
            True,
            "contactRoleId":
            "",  # 联系人角色ID
            "extFields": {},  # 自定义字段
            "content":
            "接口写跟进,没填写自定义字段" + str(random.randint(100, 10000))  # 跟进内容
        }
        if "tags" in cust_data:
            data["tags"] = cust_data["tags"]
        if "contacts" in cust_data:
            data["contactId"] = cust_data["contacts"][0]["id"]
            data["contactName"] = cust_data["contacts"][0]["name"]
            if len(cust_data["contacts"][0]["tel"]) != 0:
                data["contactPhone"] = cust_data["contacts"][0]["tel"][0]
            elif len(cust_data["contacts"][0]["wiretel"]) != 0:
                data["contactPhone"] = cust_data["contacts"][0]["wiretel"][0]
            if "contactRoleId" in cust_data["contacts"][0]:
                data["contactRoleId"] = cust_data["contacts"][0][
                    "contactRoleId"]
        '''
        # 测试提醒时时间时写的循环
        for i in range(1, 30, 3):
            data["remindAt"] = int(datetime.now().timestamp()) + 7*86400 + i*60 - 3600*7
            data["content"] = "发布后写的跟进" + str(random.randint(100, 10000))
        '''
        result = fo.create_follow(data)

        self.assertEqual(result.status_code, 200, msg=result.text)
        result_json = result.json()
        self.assertEqual(result_json['errcode'], 0, msg=result.text)
        self.assertEqual(result_json['errmsg'], 'success', msg=result.text)
        # 断言下跟进内容
        follow_response = result_json["data"]
        self.assertEqual(data["content"],
                         follow_response["content"],
                         msg='跟进内容与填写不一致')  # 检查客户名称、跟进内容、记录行为、下次跟进时间等是否一致
        self.assertEqual(data["customerId"],
                         follow_response["customerId"],
                         msg='客户ID与所填写不一致')
        self.assertEqual(data["typeId"],
                         follow_response["typeId"],
                         msg='记录行为ID与所填写不同')
        self.assertEqual(data["remindAt"],
                         follow_response["remindAt"],
                         msg="下次跟进时间错误")
예제 #13
0
 def setUpClass(cls):
     cls.cust = customerManger.CustomerManger()
     cls.fo = follow.Follow()
     cls.org = user.User()
     print("快速记录测试:start")
예제 #14
0
    def test_CreateWorkReport(self):
        """测试新建报告用例:正常新建报告"""
        reportType = 3
        # "报告类型,int,1:日报,2:周报,3:月报"
        if reportType == 1:
            T = get_Time_Type.getTimeRegionByType('Today')
            beginAt = T[0]
            endAt = T[1]
        elif reportType == 2:
            T = get_Time_Type.getTimeRegionByType('TheWeek')
            beginAt = T[0]
            endAt = T[1]
        elif reportType == 3:
            T = get_Time_Type.getTimeRegionByType('TheMonth')
            beginAt = T[0]
            endAt = T[1]
        else:
            print('报告类型错误!')
            beginAt = 0
            endAt = 0

        wr = workReport.WorkReport()
        u = user.User()
        reviewer = u.get_User('刘洋C')  # 返回类型为字典
        members = [u.get_User('陈老师'), u.get_User('李明A')]
        workreport_request = {
            "activityStat":
            True,
            "content":
            "新建报告" +
            time.strftime('%Y-%m-%d %H:%M', time.localtime(time.time())),
            "crmDatas":
            wr.get_CrmData(beginAt, endAt).json(),
            "members": {
                "users": members
            },
            "beginAt":
            beginAt,
            "endAt":
            endAt,
            "uuid":
            "",
            "type":
            reportType,
            "isDelayed":
            False,
            "reviewer": {
                "user": reviewer
            }
        }

        result = wr.creat_WorkReport(workreport_request)
        self.assertEqual(result.status_code, 200)
        workreport_response = result.json()
        print("报告详情:", workreport_response)
        # 返回类型为字典
        self.assertEqual(workreport_request['type'],
                         workreport_response['type'],
                         msg='报告类型错误')  # 验证报告类型是否与提交一致
        self.assertEqual(workreport_request["beginAt"],
                         workreport_response["beginAt"],
                         msg='报告日期错误')  # 验证报告日期是否与提交一致
        self.assertEqual(workreport_request["endAt"],
                         workreport_response["endAt"])
        self.assertEqual(workreport_request['content'],
                         workreport_response['content'])  # 验证报告内容是否与提交一致
        self.assertEqual(workreport_request['crmDatas'],
                         workreport_response['crmDatas'])  # 验证跟进统计是否与提交一致
예제 #15
0
 def setUpClass(cls):
     print("审批流程:start")
     cls.wfin = wfinstance.Wfinstance()
     cls.param = {"pageSize": 20}
     cls.cus = customerManger.CustomerManger()  # 定义一个客户对象
     cls.us = user.User()