def test_Wreport_Search(self): """测试报告列表搜索:关键字“测试周报""" startAt, endAt = get_Time_Type.getTimeRegionByType('TheMonth') param = { 'pageIndex': 1, 'pageSize': 20, 'reportType': 0, 'isReviewed': 0, 'sendType': 0, 'keyword': '测试周报' } result = self.wreport.get_MyWrportlist(param) self.assertEqual(result.status_code, 200) records = result.json()['records'] totalRecords = result.json()['totalRecords'] if totalRecords > param["pageSize"]: page = math.ceil(totalRecords / param["pageSize"]) for p in range(2, page + 1): param["pageIndex"] = p pageResult = self.wreport.get_MyWrportlist(param) json = pageResult.json() pagedata = json["records"] records.extend(pagedata) print("搜索结果报告数量", len(records)) self.assertEqual(totalRecords, len(records), msg='返回总数与实际数量总数不同') # 判断返回的数据总数与实际数据数量是否相同
def test_get_CrmData(self): """测试报告中跟进统计用例:获取本月跟进统计""" begainAT, endAt = get_Time_Type.getTimeRegionByType('TheMonth') r = self.wreport.get_CrmData(begainAT, endAt) print("111", r.text) self.assertEqual(r.status_code, 200) Tp = isinstance(r.json(), list) # 看返回类型是不是一个list数组 self.assertTrue(Tp)
def test_eventList_003(self): """我执行的:最近30天已完成数据按完成时间倒叙""" self.param["status"] = 2 self.param["field"] = "finishedAt" # 按完成时间倒叙 self.param["orderBy"] = "desc" self.param["qType"] = 2 # 按完成时间、最近30天查询 self.param["startAt"], self.param[ "endAt"] = get_Time_Type.getTimeRegionByType("TheLast30Day") self.listProcess(self.param, self.speed.event_list, "event_list")
def test_followList_001(self): """跟进时间最近30天,跟进时间倒序组合查询""" start_at, end_at = get_Time_Type.getTimeRegionByType("TheLast30Day") param = { "startAt": start_at, "endAt": end_at, "visitType": 2, # 2代表跟进记录,3代表商务电话,5智能办公电话 "field": "createdAt", # 排序字段 "filterTimeType": 1, # "时间过滤字段 1:跟进时间 2:下次跟进时间" "orderBy": "desc", "method": 0, # 跟进类型0:全部 1:开发客户跟进 2:线索跟进 3:签约客户跟进 "pageIndex": 1, "pageSize": 10, "split": 1 # 附件是否分割为图片和文件2个数组 } result = self.fo.follow_list(param) 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) data = result_json["data"] total_records = data["totalRecords"] records = data["records"] if total_records == 0: self.assertTrue(records is None, msg=result.text) return None first_at = records[0]["createdAt"] actual_total = len(records) for fol in records: self.assertTrue(first_at >= fol["createdAt"]) # 断言列表按创建时间倒叙排序 self.assertTrue( start_at <= fol["createdAt"] <= end_at) # 判断第一页返回的数据属于最近30天新建的 first_at = fol["createdAt"] 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.fo.follow_list(param) self.assertEqual(page_result.status_code, 200, msg=page_result.text) page_json = page_result.json() self.assertEqual(page_json["errcode"], 0, msg=page_result.text) self.assertEqual(page_json["errmsg"], "success", msg=page_result.text) page_records = page_json["data"]["records"] actual_total += len(page_records) for fol in page_records: self.assertTrue( first_at >= fol["createdAt"]) # 判断列表按创建时间倒叙排序 self.assertTrue(start_at <= fol["createdAt"] <= end_at) # 判断返回的数据属于最近30天新建的 first_at = fol["createdAt"] print("快速记录最近30天实际跟进数量", actual_total) self.assertEqual(total_records, actual_total) # 判断返回的总数是否与实际数量相同
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']) #判断报告内容是否语体教相同
def getID(self): startAt, endAt = get_Time_Type.getTimeRegionByType('TheMonth') param = { 'pageIndex': 1, 'pageSize': 20, 'reportType': 0, 'isReviewed': 1, 'sendType': 0, 'startAt': startAt, 'endAt': endAt } result = self.get_MyWrportlist(param) if result.status_code == 200: if len(result.json()['records']) > 0: return result.json()['records'][0]['id'] else: print('用户无可编辑的报告')
def test_VisitList(self): '''拜访签到列表默认展示数据:最近30天,创建时间倒叙''' param = { "customerType": 0, #0全部,1开发客户,2签约客户 "filterType ": 0, "pageIndex ": 1, "pageSize": 10, "timeType": 17, #表示最近30天 "userId": '', "xpath": "" } v = visit.Visit() result = v.visitList(param) self.assertEqual(result.status_code, 200) data = result.json()["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 = v.visitList(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("最近30天拜访数量", len(records)) self.assertEqual(totalRecords, len(records), msg='返回数据实际数量与总数不同') #判断返回的总数是否与实际数量相同 startAt, endAt = get_Time_Type.getTimeRegionByType( "TheLast30Day") #获取最近30天的时间戳 if totalRecords > 0: firstAt = records[0]["createdAt"] for vi in records: self.assertTrue( startAt <= vi["createdAt"] and vi["createdAt"] <= endAt) #判断第一页返回的数据属于最近30天新建的 self.assertTrue(firstAt >= vi["createdAt"]) #判断列表按创建时间倒叙排序 firstAt = vi["createdAt"]
def test_followList_004(self): """下次跟进时间本月+跟进对象+下次跟进时间顺序组合筛选""" start_at, end_at = get_Time_Type.getTimeRegionByType("TheMonth") param = { "startAt": start_at, "endAt": end_at, "visitType": 2, # 2代表跟进记录,3代表商务电话,5智能办公电话 "field": "remindAt", # 排序字段 "filterTimeType": 2, # "时间过滤字段 1:跟进时间 2:下次跟进时间" "orderBy": "asc", "method": 2, # 跟进类型0:全部 1:开发客户跟进 2:线索跟进 3:签约客户跟进 "pageIndex": 1, "pageSize": 10, "split": 1 # 附件是否分割为图片和文件2个数组 } result = self.fo.follow_list(param) 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) data = result_json["data"] total_records = data["totalRecords"] records = data["records"] if total_records == 0: self.assertTrue(records is None, msg=result.text) return None first_at = records[0]["remindAt"] actual_total = len(records) for fol in records: self.assertEqual( fol["customerType"], 0, msg=fol["remindAt"]) # customerType客户类型 0.销售线索 1.开发客户 2.签约客户 self.assertTrue(first_at <= fol["remindAt"], msg=fol["remindAt"]) # 断言列表按下次提醒时间顺序排序 self.assertTrue(start_at <= fol["remindAt"] <= end_at, msg=fol["remindAt"]) # 判断第一页返回的数据属于下次提醒时间属于本月 first_at = fol["remindAt"] 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.fo.follow_list(param) self.assertEqual(page_result.status_code, 200, msg=page_result.text) page_json = page_result.json() self.assertEqual(page_json["errcode"], 0, msg=page_result.text) self.assertEqual(page_json["errmsg"], "success", msg=page_result.text) page_records = page_json["data"]["records"] actual_total += len(page_records) for fol in page_records: self.assertEqual(fol["customerType"], 0, msg=fol["remindAt"] ) # customerType客户类型 0.销售线索 1.开发客户 2.签约客户 self.assertTrue(first_at <= fol["remindAt"], msg=fol["remindAt"]) # 断言列表按下次提醒时间顺序排序 self.assertTrue( start_at <= fol["remindAt"] <= end_at, msg=fol["remindAt"]) # 判断第一页返回的数据属于下次提醒时间属于本月 first_at = fol["remindAt"] print("快速记录下次提醒时间为本月的线索跟进数量:", actual_total) self.assertEqual(total_records, actual_total) # 判断返回的总数是否与实际数量相同
def test_followList_002(self): """跟进时间最近7天,下次跟进时间倒叙组合查询""" start_at, end_at = get_Time_Type.getTimeRegionByType("LastSevenDay") param = { "field": "remindAt", # 排序字段 "orderBy": "desc", # 排序方式 asc:升序 desc:降序 "filterTimeType": 1, # "时间过滤字段 1:跟进时间时间 2:下次跟进时间" "startAt": start_at, "endAt": end_at, "method": 0, # 跟进类型0:全部 1:开发客户跟进 2:线索跟进 3:签约客户跟进 "visitType": 2, # 2代表跟进记录,3代表商务电话,5智能办公电话 "pageIndex ": 1, "pageSize": 10, "split": 1 # 图片和文件分开 } result = self.fo.follow_list(param) 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) total_records = result_json["data"]["totalRecords"] records = result_json["data"]["records"] # list if total_records == 0: self.assertEqual(records, None) return actual_total = len(records) first_at = records[0]["remindAt"] for fol in records: self.assertTrue( param["startAt"] <= fol["createAt"] <= param["endAt"], msg=fol["createAt"]) # 断言跟进时间属于最近7天 if "remindAt" not in fol: continue self.assertTrue(first_at >= fol["remindAt"], msg=fol["remindAt"]) # 断言下次提醒时间倒叙排序 first_at = fol["remindAt"] 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.fo.follow_list(param) self.assertEqual(page_result.status_code, 200, msg=page_result.text) page_json = page_result.json() self.assertEqual(page_json["errmsg"], "success", msg=p) page_records = page_json["data"]["records"] actual_total += len(page_records) for fol in page_records: # 断言跟进时间属于最近7天 self.assertTrue( param["startAt"] <= fol["createAt"] <= param["endAt"], msg=fol["createAt"]) if "remindAt" not in fol: continue self.assertTrue(first_at >= fol["remindAt"], msg=fol["remindAt"]) # 断言下次提醒时间倒叙排序 first_at = fol["remindAt"] self.assertEqual(total_records, actual_total, msg="返回的数据总数与实际数据数量不符") print("快速记录最近7天实际跟进数量", actual_total)
else: print('用户无可编辑的报告') ''' #获取团队列表 def get_Teamlist(self,param): url='https://ukuaiqi.com/p/oa/api/v2/oa/wreport/query/web/team' params={ 'pageIndex':pageIndex, 'pageSize':pageSize , 'sortBy':sortBy, 'order':order, 'isReviewed':isReviewed, 'keyword' :keyword, 'xpath' :xpath, 'userId':userId, 'startAt':startAt, 'endAt':endAt, 'sort':sort } result=requests.get(url,params=params,headers=self.header) return result ''' if __name__ == '__main__': w = WorkReport() startAt, endAt = get_Time_Type.getTimeRegionByType('TheMonth') # result=w.get_MyWrportlist(startAt, endAt,reportType=0,isReviewed=0,sendType=0) print(w.get_CrmData(startAt, endAt).text)
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']) # 验证跟进统计是否与提交一致