def create_transaction_deal(self): self.s = requests.session() # 登记出售房源并获取房源id self.sale_caseid, self.sale_no = HouseManage.HouseManage( ).get_saleHouse_caseNo() # 登记求购客源并获取id self.caseid, self.header = CustomerManage.CustomerManage( ).create_BuyCustomer() # 获取出售中未使用的合同编号 self.codeNo, self.headers = CustomerManage.CustomerManage( ).get_buyMatchNotAllocatedDealCode() # 读取出excel中的测试数据 case = readexcel.ExcelUtil(CUSTOMER_MANAGE_EXCEL_PATH, sheetName="客源管理-求购-新增合同").dict_data()[1] print(case) a = json.loads(case["body"]) case["headers"] = self.headers a["custId"] = self.caseid a["dealCustomerId"] = self.caseid a["signDate"] = get_date.GetDate().get_today_str_data() a["contractNo"] = self.codeNo a["dealHouseId"] = self.sale_caseid a["dealHouseNo"] = self.sale_no b = json.dumps(a) case.update({"body": b}) res = base_api.send_requests(self.s, case) res_text = json.loads(res["text"]) return res_text["data"][ "dealId"], self.headers, self.sale_caseid, self.caseid
def insert_mgr_range(self, header): url = "http://hft.myfun7.com/erpWeb/managerCenter/organization/insertMgrRangeData" data = readexcel.ExcelUtil(ORGANIZATION_MANAGE_EXCEL_PATH, sheetName="组织管理-员工档案-增加片区").dict_data() data = json.loads(data[0]["body"]) res = requests.post(url=url, headers=header, json=data) return res.json()["data"]["regId"]
def create_SaleHouse_unitPriceHigh(self): headers = add_clientkey_to_headers.get_clientkey() url = "http://hft.myfun7.com/houseWeb/funSale/createFunSale" data = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="房源管理-出售排序-登记").dict_data() data = json.loads(data[5]["body"]) res = requests.post(url=url, headers=headers, json=data) return res.json()["data"]["caseId"], headers
class GetHouseStatus(unittest.TestCase): @classmethod def setUpClass(cls): cls.s = requests.session() #创建5个出售房源 lst = [] for i in range(0, 5): caseid, headers = HouseManage().create_houseSale() a = caseid lst.append(a) print(lst) #分别将创建的5个房源写成封盘、预定、暂缓、内成交以及外成交状态 cls.caseid_a = HouseStatus().create_fengPan(lst[0]) cls.caseid_b = HouseStatus().create_yuDing(lst[1]) cls.caseid_c = HouseStatus().create_zanHuan(lst[2]) cls.caseid_d = HouseStatus().create_neiChengJiao(lst[3]) cls.caseid_e = HouseStatus().create_waiChengJiao(lst[4]) sleep(5) return lst @classmethod def tearDownClass(cls): #删除登记的房源 code_a = HouseManage().delete_houseSale(cls.caseid_a) code_b = HouseManage().delete_houseSale(cls.caseid_b) code_c = HouseManage().delete_houseSale(cls.caseid_c) code_d = HouseManage().delete_houseSale(cls.caseid_d) code_e = HouseManage().delete_houseSale(cls.caseid_e) if code_a == 200 and code_b == 200 and code_c == 200 and code_d == 200 and code_e == 200: print("房源删除成功") else: print("房源删除失败") testdata = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="房源管理-出售-房源状态").dict_data() print(testdata) @ddt.data(*testdata) def test_get_HouseStatus(self, case): case["headers"] = add_clientkey_to_headers.get_clientkey() res = base_api.send_requests(self.s, case) # 检查点 checkpoint check = case["checkpoint"] # 获取检查点中的内容 check = json.loads(check) # json字符串转为字典 print("检查点->:%s" % check) # 返回结果 res_text = res["text"] # 获取响应的内容 res_text = json.loads(res_text) # 将响应的内容转换为字典 print("返回实际结果->:%s" % res_text) # 断言 sleep(5) self.assertEqual(check.get("userName"), res_text["data"]["saleList"][0]["userName"]) self.assertEqual(check.get("saleSubject"), res_text["data"]["saleList"][0]["saleSubject"])
def get_SoSo_houseSale(self): headers=add_clientkey_to_headers.get_clientkey() url="http://hft.myfun7.com/sosoWeb/soso/house/getSoSoSaleList" data=readexcel.ExcelUtil(SOSO_EXCEL_PATH,sheetName="搜搜-出售信息").dict_data() data=json.loads(data[0]["body"]) res=requests.post(url=url,headers=headers,json=data) print(res.json()["data"][0]["id"]) return str(res.json()["data"][0]["id"]),headers
def create_RentCustomer_HighPrice(self): headers = add_clientkey_to_headers.get_clientkey() url = "http://hft.myfun7.com/houseWeb/erp/rentCust/createRentCustomer" data = readexcel.ExcelUtil(CUSTOMER_MANAGE_EXCEL_PATH, sheetName="客源管理-求租排序-登记").dict_data() data = json.loads(data[3]["body"]) res = requests.post(url=url, headers=headers, json=data) return res.json()["data"]["caseId"], headers
class GetBuyHouseList_SaleRoomQuery(unittest.TestCase): @classmethod def setUpClass(cls): # 保持登录状态 cls.s = requests.session() cls.header = add_clientkey_to_headers.get_clientkey() testdata = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="房源管理-出售-户型查询").dict_data() @ddt.data(*testdata) def test_getBuyHouseList_SaleRoomQuery(self, case): case["headers"] = self.header res = base_api.send_requests(self.s, case) # 检查点 checkpoint check = case["checkpoint"] # 获取检查点中的内容 check = json.loads(check) # json字符串转为字典 print("检查点->:%s" % check) # 返回结果 res_text = res["text"] # 获取响应的内容 res_text = json.loads(res_text) # 将响应的内容转换为字典 print("返回实际结果->:%s" % res_text) buy_sale_house_datas = res_text["data"]["saleList"] #判断传入的户型参数存在一定区间 if "roomNumHigh" and "roomNumLow" in check.keys(): if len(buy_sale_house_datas) > 0: #将一定户型的出售房源数据获取出来 lst = [] for i in buy_sale_house_datas: buy_sale_house_data = i["saleRoom"] lst.append(buy_sale_house_data) #断言 self.assertIn(check.get("roomNumHigh"), lst) self.assertIn(check.get("roomNumLow"), lst) self.assertEqual(check.get("errCode"), res_text["errCode"]) else: self.assertEqual(check.get("errCode"), res_text["errCode"]) print("不存在此区间户型的出售户型") else: if len(buy_sale_house_datas) > 0: #将一定户型的出售房源数据获取出来 lst = [] for i in buy_sale_house_datas: buy_sale_house_data = i["saleRoom"] lst.append(buy_sale_house_data) #断言 self.assertIn(check.get("saleRoom"), lst) self.assertEqual(check.get("errCode"), res_text["errCode"]) else: self.assertEqual(check.get("errCode"), res_text["errCode"]) print("不存在此区间户型的出售户型")
def create_attendance_scope(self): headers = add_clientkey_to_headers.get_clientkey() url = "http://hft.myfun7.com/erpWeb/managerCenter/attendanceScopeModule/addEditAttendanceScope" data = readexcel.ExcelUtil(ATTENDANCE_MANAGE_EXCEL_PATH, sheetName="考勤管理-考勤配置-新增考勤地点").dict_data() data = json.loads(data[0]["body"]) res = requests.post(url=url, headers=headers, json=data) print(res.json()["data"]) return res.json()["data"], headers
def get_SoSo_houseSalePhone(self): self.id,self.headers=self.get_SoSo_houseSale() url="http://hft.myfun7.com/erpWeb/soso/house/getSOSOConvertDetectData" data = readexcel.ExcelUtil(SOSO_EXCEL_PATH, sheetName="搜搜-查看电话").dict_data() dict_data = json.loads(data[0]["body"]) dict_data.update({"sosoId":self.id}) res = requests.post(url=url, headers=self.headers, json=dict_data) print(res.json()["data"][0]["phone"]) return str(res.json()["data"][0]["phone"]),self.id,self.headers
def get_houseFloorMenu(self): headers = add_clientkey_to_headers.get_clientkey() url = "http://hft.myfun7.com/erpWeb/managerCenter/buildRule/getHouseFloorMenu" data = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="管理中心-获取楼盘信息").dict_data() data = json.loads(data[0]["body"]) res = requests.post(url=url, headers=headers, json=data) lst_data = res.json()["data"]["buildInfoVOS"][0] return lst_data["buildId"]
def insert_mgr_area(self): headers = add_clientkey_to_headers.get_clientkey() url = "http://hft.myfun7.com/erpWeb/managerCenter/organization/insertMgrArea" data = readexcel.ExcelUtil(ORGANIZATION_MANAGE_EXCEL_PATH, sheetName="组织管理-员工档案-增加大区").dict_data() data = json.loads(data[0]["body"]) res = requests.post(url=url, headers=headers, json=data) print(res.json()["data"]["areaId"]) return res.json()["data"]["areaId"], headers
def create_paymentTask(self,money): clientkey = login_get_clientkey.login() header = readexcel.ExcelUtil(USER_MANAGE_EXCEL_PATH,sheetName="创建充值金额接口").dict_data()[0] headers = json.loads(header["headers"]) headers["CLIENTKEY"] = clientkey url="http://admin.myfun7.com/adminWeb/payment/cashRecharge/createPaymentTask" data={"deptId":"293846", "cityId":"1","archiveId":"1336698", "payModel":"1","isRechargeComp":"0","totalMoney": money} r=requests.post(url,headers=headers, data=data) return r.json()["data"]["ptId"], r.json()["data"]["token"]
class LeaseHouseAreaOrder(unittest.TestCase): @classmethod def setUpClass(cls): # 保持登录状态 cls.s = requests.session() #创建出租中按照面积来排序的房源 cls.Lower_caseid = HouseManage.LeaseHouseOrder( ).create_LeaseHouse_LowerArea() sleep(5) cls.High_caseid, cls.headers = HouseManage.LeaseHouseOrder( ).create_LeaseHouse_HighArea() sleep(10) @classmethod def tearDownClass(cls): lower_coed = HouseManage.HouseManage().delete_leaseHouse( cls.Lower_caseid) sleep(5) high_code = HouseManage.HouseManage().delete_leaseHouse( cls.High_caseid) if lower_coed == 200 and high_code == 200: print("房源删除成功") else: print("房源删除失败") #出租房源按照总面积排序 data = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="房源管理-出租-总面积排序").dict_data() print(data) @ddt.data(*data) def test_leaseHouse_total_AreaOrder(self, case): case["headers"] = self.headers res = base_api.send_requests(self.s, case) # 检查点 checkpoint check = case["checkpoint"] # 获取检查点中的内容 check = json.loads(check) # json字符串转为字典 print("检查点->:%s" % check) # 返回结果 res_text = res["text"] # 获取响应的内容 res_text = json.loads(res_text) # 将响应的内容转换为字典 print("返回实际结果->:%s" % res_text) # 断言 self.assertEqual(check.get("leaseArea"), res_text["data"]["leaseList"][0]["leaseArea"]) self.assertEqual(check.get("buildName"), res_text["data"]["leaseList"][0]["buildName"]) self.assertEqual(check.get("leaseSubject"), res_text["data"]["leaseList"][0]["leaseSubject"])
class BuyCustomerOrder(unittest.TestCase): @classmethod def setUpClass(cls): # 保持登录状态 cls.s = requests.session() #创建求租中按照价格来排序的房源 cls.Lower_caseid = CustomerManage.CustomerManage( ).create_RentCustomer_LowerPrice() cls.High_caseid, cls.headers = CustomerManage.CustomerManage( ).create_RentCustomer_HighPrice() @classmethod def tearDownClass(cls): lower_coed = CustomerManage.CustomerManage().delete_rentCustomer( cls.Lower_caseid) high_code = CustomerManage.CustomerManage().delete_rentCustomer( cls.High_caseid) if lower_coed == 200 and high_code == 200: print("房源删除成功") else: print("房源删除失败") # 求租客源按照总价格排序 data = readexcel.ExcelUtil(CUSTOMER_MANAGE_EXCEL_PATH, sheetName="客源管理-求租-租金排序").dict_data() print(data) @ddt.data(*data) def test_rentCustomer_total_PriceOrder(self, case): case["headers"] = self.headers res = base_api.send_requests(self.s, case) # 检查点 checkpoint check = case["checkpoint"] # 获取检查点中的内容 check = json.loads(check) # json字符串转为字典 print("检查点->:%s" % check) # 返回结果 res_text = res["text"] # 获取响应的内容 res_text = json.loads(res_text) # 将响应的内容转换为字典 print("返回实际结果->:%s" % res_text) # 断言 self.assertEqual( check.get("housePriceHigh"), res_text["data"]["rentCustomers"][0]["housePriceHigh"]) self.assertEqual( check.get("buildName"), (res_text["data"]["rentCustomers"][0]["buildName"]).strip())
class GetBuyHouseList_AreaQuery(unittest.TestCase): @classmethod def setUpClass(cls): # 保持登录状态并获取到clientkey值 cls.s = requests.session() cls.header = add_clientkey_to_headers.get_clientkey() testdata = readexcel.ExcelUtil(CUSTOMER_MANAGE_EXCEL_PATH, sheetName="客源管理-求购-面积查询").dict_data() @ddt.data(*testdata) def test_getBuyHouseList_AreaQuery(self, case): case["headers"] = self.header res = base_api.send_requests(self.s, case) # 检查点 checkpoint check = case["checkpoint"] # 获取检查点中的内容 check = json.loads(check) # json字符串转为字典 print("检查点->:%s" % check) #将检查点的数据组装成一个列表 lst_check = [] high_data = check.get("houseAreaHigh") lst_check.append(high_data) low_data = check.get("houseAreaLow") lst_check.append(low_data) # 返回结果 res_text = res["text"] # 获取响应的内容 res_text = json.loads(res_text) # 将响应的内容转换为字典 print("返回实际结果->:%s" % res_text) buy_list = res_text["data"]["buyCustomers"] if len(buy_list) > 0: #将一定区间面积的求购客源的数据获取出来 lst = [] for i in buy_list: buy_area_high = i["houseAreaHigh"] lst.append(buy_area_high) buy_area_low = i["houseAreaLow"] lst.append(buy_area_low) #断言 self.assertIn(lst_check[0], lst) self.assertIn(lst_check[1], lst) self.assertEqual(check.get("code"), res_text["code"]) else: self.assertEqual(check.get("code"), res_text["code"]) print("不存在此区间面积的求购客源")
class SaleHouseUnitPriceOrder(unittest.TestCase): @classmethod def setUpClass(cls): # 保持登录状态 cls.s = requests.session() #创建出售中按照单价来排序的房源 cls.Lower_caseid = HouseManage.SaleHouseOrder( ).create_SaleHouse_unitPriceLow() cls.High_caseid, cls.headers = HouseManage.SaleHouseOrder( ).create_SaleHouse_unitPriceHigh() sleep(10) @classmethod def tearDownClass(cls): lower_coed = HouseManage.HouseManage().delete_houseSale( cls.Lower_caseid) high_code = HouseManage.HouseManage().delete_houseSale(cls.High_caseid) if lower_coed == 200 and high_code == 200: print("房源删除成功") else: print("房源删除失败") #出售房源按照单价排序 data = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="房源管理-出售-单价排序").dict_data() print(data) @ddt.data(*data) def test_saleHouse_unit_PriceOrder(self, case): case["headers"] = self.headers res = base_api.send_requests(self.s, case) # 检查点 checkpoint check = case["checkpoint"] # 获取检查点中的内容 check = json.loads(check) # json字符串转为字典 print("检查点->:%s" % check) # 返回结果 res_text = res["text"] # 获取响应的内容 res_text = json.loads(res_text) # 将响应的内容转换为字典 print("返回实际结果->:%s" % res_text) # 断言 self.assertEqual(check.get("saleUnitPrice"), res_text["data"]["saleList"][0]["saleUnitPrice"]) self.assertEqual(check.get("buildName"), res_text["data"]["saleList"][0]["buildName"]) self.assertEqual(check.get("errCode"), res_text["errCode"])
def add_InviteUserInfo(self): self.header = add_clientkey_to_headers.get_clientkey() url = "http://hft.myfun7.com/erpWeb/managerCenter/organization/addInviteUserInfo" data = readexcel.ExcelUtil(ORGANIZATION_MANAGE_EXCEL_PATH, sheetName="邀请注册接口").dict_data()[0] dic_data = json.loads(data["body"]) dic_data["userMobile"] = untils.CreatePhone().create_phone() str_data = json.dumps(dic_data) data.update({"body": str_data}) r = requests.post(url, headers=self.header, json=json.loads(data["body"])) return (dic_data["serviceReg"], dic_data["serviceZoneIds"], dic_data["serviceZone"], dic_data["userMobile"], self.header, dic_data["userName"])
class GetSaleHouseList_useageQuery(unittest.TestCase): @classmethod def setUpClass(cls): # 保持登录状态并获取到clientkey值 cls.s = requests.session() cls.header = add_clientkey_to_headers.get_clientkey() @classmethod def tearDownClass(cls): clientkey = cls.header["CLIENTKEY"] Logout_Systerm.Logout(clientkey) testdata = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="房源管理-出售-房源用途查询").dict_data() @ddt.data(*testdata) def test_getSaleHouseList_useageQuery(self, case): case["headers"] = self.header res = base_api.send_requests(self.s, case) # 检查点 checkpoint check = case["checkpoint"] # 获取检查点中的内容 check = json.loads(check) # json字符串转为字典 print("检查点->:%s" % check) # 返回结果 res_text = res["text"] # 获取响应的内容 res_text = json.loads(res_text) # 将响应的内容转换为字典 print("返回实际结果->:%s" % res_text) sale_list = res_text["data"]["saleList"] if len(sale_list) > 0: #将返回值中用途值获取出来 lst = [] for i in sale_list: sale_useage = i["saleUseage"] lst.append(sale_useage) lst_data = list(set(lst)) if len(lst_data) == 1: #断言 self.assertEqual(check.get("saleUseage"), lst[0]) self.assertEqual(check.get("errCode"), res_text["errCode"]) else: print("搜索出房源的用途不全为对应房源") else: self.assertEqual(check.get("errCode"), res_text["errCode"]) print("不存在对应用途的房源")
def Logout(clientkey): s = requests.session() data = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="退出系统").dict_data() header_data = data[0]["headers"] a = json.loads(header_data) a["CLIENTKEY"] = clientkey b = json.dumps(a) data[0].update({"headers": b}) res = base_api.send_requests(s, data[0]) res_text = res["text"] #获取返回的值 res_texts = json.loads(res_text) #将返回的值转化为字典 result_data = res_texts.get("DATA")[0]["RESULT"] if result_data == "SUCCESS": print("退出系统状态:%s" % (result_data)) else: print("退出系统状态:%s" % (result_data))
class GetSaleHouseList_BuildNameQuery(unittest.TestCase): @classmethod def setUpClass(cls): # 保持登录状态 cls.s = requests.session() cls.build_id = HouseManage.GetHouseFloorMenu().get_houseFloorMenu() testdata = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="房源管理-出售-楼盘名查询").dict_data() @ddt.data(*testdata) def test_getSaleHouseList_BuildNameQuery(self, case): case["headers"] = add_clientkey_to_headers.get_clientkey() a = json.loads(case["body"]) a["buildId"] = self.build_id b = json.dumps(a) case.update({"body": b}) res = base_api.send_requests(self.s, case) # 检查点 checkpoint check = case["checkpoint"] # 获取检查点中的内容 check = json.loads(check) # json字符串转为字典 print("检查点->:%s" % check) # 返回结果 res_text = res["text"] # 获取响应的内容 res_text = json.loads(res_text) # 将响应的内容转换为字典 print("返回实际结果->:%s" % res_text) sale_list = res_text["data"]["saleList"] if len(sale_list) > 0: #将楼盘名获取出来 lst = [] for i in sale_list: build_name = i["buildName"] lst.append(build_name) print(lst) lst_set = list(set(lst)) print(lst_set) if len(lst_set) == 1: self.assertEqual(check.get("buildName"), lst_set[0]) else: print("楼盘名不一致") else: print("不存在楼盘名为:%s" % (check.get("buildName")))
class ModifyPwd(unittest.TestCase): @classmethod def setUpClass(cls): cls.s = requests.session() cls.header = add_clientkey_to_headers.get_clientkey() def tearDown(self): #将密码重置为修改前的密码 url = "http://hft.myfun7.com/erpWeb/usercenter/modifyPwd" header = self.header data = { "loginPassword": "******", "oldLoginPassword": self.data_pwd } re = requests.post(url=url, headers=header, json=data) if re.json()["errCode"] == 200: print("密码重置成功") else: print("密码重置失败") testdata = readexcel.ExcelUtil(USER_MANAGE_EXCEL_PATH, sheetName="修改密码接口").dict_data() @ddt.data(*testdata) def test_modify_pwd(self, data): data["headers"] = self.header res = base_api.send_requests(self.s, data) # 检查点 checkpoint check = data["checkpoint"] # 获取检查点中的内容 check = json.loads(check) # json字符串转为字典 str_pwd = data["body"] pwd_data = json.loads(str_pwd) self.data_pwd = pwd_data["loginPassword"] print("检查点->:%s" % check) # 返回结果 res_text = res["text"] # 获取响应的内容 res_text = json.loads(res_text) # 将响应的内容转换为字典 print("返回实际结果->:%s" % res_text) #断言 self.assertEqual(check.get("errCode"), res_text["errCode"])
class GetLeaseHouseList_PriceQuery(unittest.TestCase): @classmethod def setUpClass(cls): # 保持登录状态 cls.s = requests.session() testdata = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="房源管理-出租-租金查询").dict_data() @ddt.data(*testdata) def test_getLeaseHouseList_PriceQuery(self, case): case["headers"] = add_clientkey_to_headers.get_clientkey() res = base_api.send_requests(self.s, case) # 检查点 checkpoint check = case["checkpoint"] # 获取检查点中的内容 check = json.loads(check) # json字符串转为字典 print("检查点->:%s" % check) # 返回结果 res_text = res["text"] # 获取响应的内容 res_text = json.loads(res_text) # 将响应的内容转换为字典 print("返回实际结果->:%s" % res_text) lease_list = res_text["data"]["leaseList"] if len(lease_list) > 0: #将一定区间租金的出租房源的数据获取出来 lst = [] for i in lease_list: lease_price = i["leaseTotalPrice"] lst.append(lease_price) lst.sort() #将出租房源租金从小到大排序 #断言 self.assertGreaterEqual(check.get("leaseTotalPrice"), lst[-1]) #a>=b self.assertLessEqual(check.get("leaseLowPrice"), lst[0]) #a<=b self.assertEqual(check.get("errCode"), res_text["errCode"]) else: self.assertEqual(check.get("errCode"), res_text["errCode"]) print("不存在此区间租金的出租房源")
# coding:utf-8 # 作者:hejun import unittest, ddt import requests, json from common import base_api, AttendanceManage from common import readexcel from config import * from common import add_clientkey_to_headers # 读取出excel中的测试数据 testdata = readexcel.ExcelUtil(ATTENDANCE_MANAGE_EXCEL_PATH, sheetName="考勤管理-新增考勤班次").dict_data() print(testdata) @ddt.ddt class TestAddAttendanceClass(unittest.TestCase): @classmethod def setUpClass(cls): # 登录获取clientkey cls.s = requests.session() header = add_clientkey_to_headers.get_clientkey() cls.header = header def tearDown(self): # 删除考勤班次 if "data" in self.res_text.keys(): id = self.res_text["data"] code = AttendanceManage.AttendanceManage().delete_attendance_class( self.header, id)
# coding:utf-8 # 作者:hejun import unittest, ddt, time import requests, json from common import base_api, HouseManage from common import readexcel from config import * #读取出excel中的测试数据 testdata = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="房源管理-出售-提交钥匙").dict_data() print(testdata) @ddt.ddt class TestHouseManager(unittest.TestCase): @classmethod def setUpClass(cls): # 如果有登录的话,就在这里先登录了 cls.s = requests.session() cls.caseid, cls.header = HouseManage.HouseManage().create_houseSale() @classmethod def tearDownClass(cls): code = HouseManage.HouseManage().delete_houseSale(cls.caseid) if code == 200: print("登记出售房源删除成功") @ddt.data(*testdata) def test_houseSale_submit_key(self, testdata):
# coding:utf-8 # 作者:hejun import unittest import ddt import requests, json from common import base_api, OrganizationManage from common import readexcel from config import * from common import add_clientkey_to_headers #读取出excel中的测试数据 testdata = readexcel.ExcelUtil(ORGANIZATION_MANAGE_EXCEL_PATH, sheetName="组织管理-员工档案-增加大区").dict_data() print(testdata) @ddt.ddt class InsertMgrArea(unittest.TestCase): def setUp(self): # 保持登录状态 self.s = requests.session() self.header = add_clientkey_to_headers.get_clientkey() @ddt.data(*testdata) def test_insert_mgrArea(self, case): case["headers"] = self.header res = base_api.send_requests(self.s, case) # 检查点 checkpoint
# coding:utf-8 # 作者:hejun import unittest import ddt import requests from common import base_api from common import readexcel from config import * #读取出excel中的测试数据 testdata = readexcel.ExcelUtil(HOUSE_MANAGE_EXCEL_PATH, sheetName="服务器接口").dict_data() @ddt.ddt class TestServer(unittest.TestCase): @classmethod def setUpClass(cls): # 如果有登录的话,就在这里先登录了 cls.s = requests.session() # 先复制excel数据到report # writeexcel.copy_excel(EXCEL_PATH, RESULT_PATH) @ddt.data(*testdata) def test_server(self, testdata): res = base_api.send_requests(self.s, testdata) # base_api.wirte_result(res, filename=RESULT_PATH)
# coding:utf-8 # 作者:hejun import unittest import ddt import requests, json from common import base_api, CustomerManage, get_date from common import readexcel, add_clientkey_to_headers from config import * #读取出excel中的测试数据 testdata = readexcel.ExcelUtil(CUSTOMER_MANAGE_EXCEL_PATH, sheetName="获取出售和出租未领用的合同列表").dict_data() print(testdata) @ddt.ddt class MatchNotAllocatedDealCode(unittest.TestCase): @classmethod def setUpClass(cls): # 如果有登录的话,就在这里先登录了 cls.s = requests.session() #获取clientkey cls.headers = add_clientkey_to_headers.get_clientkey() @ddt.data(*testdata) def test_matchNotAllocatedDealCode(self, case): case["headers"] = self.headers res = base_api.send_requests(self.s, case) # 检查点 checkpoint
# coding:utf-8 import unittest import ddt import os import requests from common import base_api from common import readexcel from common import writeexcel # 获取demo_api.xlsx路径 curpath = os.path.dirname(os.path.realpath(__file__)) testxlsx = os.path.join(curpath, "demo_api.xlsx") # 复制demo_api.xlsx文件到logs下 logs_path = os.path.join(os.path.dirname(curpath), "logs") reportxlsx = os.path.join(logs_path, "test_result.xlsx") testdata = readexcel.ExcelUtil(testxlsx).dict_data() @ddt.ddt class Test_api(unittest.TestCase): @classmethod def setUpClass(cls): cls.s = requests.session() # 如果有登录的话,就在这里先登录了 writeexcel.copy_excel(testxlsx, reportxlsx) # 复制xlsx @ddt.data(*testdata) def test_api(self, data): # 先复制excel数据到report res = base_api.send_requests(self.s, data) base_api.wirte_result(res, filename=reportxlsx)
import unittest, json, ddt from common import readexcel, login_get_clientkey from config import * import requests testdata = readexcel.ExcelUtil(USER_MANAGE_EXCEL_PATH, sheetName="创建充值金额接口").dict_data() print(testdata) @ddt.ddt class CreatePaymentTask(unittest.TestCase): @classmethod def setUpClass(cls): cls.s = requests.session() cls.clientkey = login_get_clientkey.login() @ddt.data(*testdata) def test_create_paymentTask(self, case): dic_header = json.loads(case["headers"]) dic_header["CLIENTKEY"] = self.clientkey dic_body_data = json.loads(case["body"]) print(dic_header) res = requests.post(url=case["url"], headers=dic_header, data=dic_body_data) # 检查点 checkpoint check = case["checkpoint"] # 获取检查点中的值 check = json.loads(check) # 将son字符串转为字典 print("检查点->:%s" % check)
# coding:utf-8 # 作者:hejun import unittest, ddt, requests, json, time from common import readexcel, OrganizationManage from config import * testdata = readexcel.ExcelUtil(ORGANIZATION_MANAGE_EXCEL_PATH, sheetName="增加员工").dict_data() @ddt.ddt class AddCompInviteUser(unittest.TestCase): def setUp(self): # 添加邀请员工信息 self.tup_data = OrganizationManage.OrganizationManage( ).add_InviteUserInfo() # print(self.tup_data) # 获取邀请链接参数 self.link_params = OrganizationManage.OrganizationManage( ).get_inviteLink(self.tup_data[4]) # print(self.link_params) # 获取邀请id self.invite_id = OrganizationManage.OrganizationManage( ).get_inviteUserId(self.link_params, self.tup_data[3]) def tearDown(self): # 按关键字查询添加的员工 time.sleep(3) # 等待返回值 data = OrganizationManage.OrganizationManage().get_UserListInfo( self.tup_data[5], self.tup_data[4])