def setUp(self): self.methon = WebMethon() self.config = Config() self.excel = OperationExcel() self.pm = PublicMethod() self.operationJson = OperationJson() self.iscontent = IsContent()
class LaGou(unittest.TestCase): def setUp(self): self.obj=Method() self.p=IsContent() self.execl=OperationExcel() self.operationJson=OperationJson() def statusCode(self,r): self.assertEqual(r.status_code, 200) self.assertEqual(r.json()['code'], 0) def isContent(self,r,row): self.statusCode(r=r) self.assertTrue(self.p.isContent(row=row,str2=r.text)) def test_laGou_001(self): '''拉钩:测试翻页''' r = self.obj.post(row=1,data=self.operationJson.getRequestsData(1)) self.isContent(r=r,row=1) self.execl.writeResult(1,'pass') def test_laGou_002(self): '''拉钩:测试关键字的职位搜索''' r =self.obj.post(row=1,data=setSo('Python开发工程师')) list1=[] for i in range(0,15): positionId=r.json()['content']['positionResult']['result'][i]['positionId'] list1.append(positionId) writePositionId(json.dumps(list1)) def test_lgGou_003(self): '''访问搜索到的每个职位的详情页信息''' for i in range(15): r=self.obj.get(url=getUrl()[i]) self.assertTrue(self.p.isContent(34,r.text))
def wcf_isIn(self, r, row): '''判断是否包含返回的内容,并打印日志''' a = IsContent() try: self.assertTrue(a.isContent(row=row, str=r)) return logger.info(r) except AssertionError as err: err_str = traceback.format_exc() logger.info(err_str) raise AssertionError('断言失败!')
class LaGou(unittest.TestCase): def setUp(self): self.obj=Method() self.p=IsContent() self.excel=OperationExcel() self.json=OperationJson() def statusCode(self,r): self.assertEqual(r.status_code,200) self.assertEqual(r.json()['code'],0) def isContent(self,r,row): self.statusCode(r) # 注意要给statusCode传数据 self.assertTrue(self.p.isContent(row=row,str2=r.text)) def test_laGou_001(self): '''拉勾:测试翻页,第一页''' r=self.obj.post(row=1,data=self.json.getRequestData(row=1)) #obj这种写法的原理是什么,见setup方法 print(r.text) self.isContent(r=r,row=1) #为什么不是写成self.p.isContent(r=r,row=1)??? self.excel.writeResult(1,'pass') def test_laGou_002(self,row=2): '''拉勾:测试翻页,第二页''' r=self.obj.post(2) #obj这种写法的原理是什么,见setup方法 self.isContent(r=r,row=row) self.excel.writeResult(2,'pass') #如果上面的断言失败了,pass就不会被写进文件中了 def test_laGou_003(self, row=3): '''拉勾:测试翻页,传入不同类型的搜索关键字,替换json中的数据进行测试''' r = self.obj.post(row=3,data=setSo('性能测试工程师')) print(r.text) list1=[] for i in range(0,15): # 0< <16 positionId=r.json()['content']['positionResult']['result'][i]['positionId'] list1.append(positionId) writePositionId(json.dumps(list1)) print(list1) # self.isContent(r=r, row=row) def test_laGou_004(self, row=4): '''拉勾:访问搜索‘性能测试工程师’查看每个职位的详情信息''' for item in getPositionId(): r=self.obj.get(url=getUrl(positionId=item)) # print(r.url) print(r.text) #因为返回的详情页面是html的,所以没有响应状态码,只需要断言数据就行 self.assertTrue(self.p.isContent(row=4,str2=r.text)) #要么写成(row=4,str2=r.text),要么写成(4,r.text),否则报错
def setup_class(self): print('类前面,我爱你') self.obj = Method() self.p = IsContent() self.execl = OperationExcel() self.operationJson = OperationJson() self.log = Log()
def isIn(self, r, row): '''判断是否包含返回的内容,并打印日志''' a = IsContent() assertHTTPCode(r, [200]) self.assertTrue(a.isContent(row=row, str=r.text)) ''' try: assertHTTPCode(r, [200]) self.assertTrue(a.isContent(row=row, str=r.text)) return logger.info(r.text) except AssertionError as err: err_str = traceback.format_exc() logger.info(err_str) raise AssertionError('断言失败!') ''' return logger.info(r.text)
class LaGou(unittest.TestCase): def setUp(self): self.obj = Method() self.p = IsContent() self.execl = OperationExcel() self.operationJson = OperationJson() def statusCode(self, r): # self.assertEqual(r.status_code, 200) print(r.json()['code']) self.assertEqual(r.json()['code'], '1001') def isContent(self, r, row): self.statusCode(r=r) self.assertTrue(self.p.isContent(row=row, str2=r.text)) def test_laGou_001(self): "sign为空" r = self.obj.post(row=1, data=set_so_keyword(userPhone="18821768014")) print("test_laGou_004 is:", r.text) self.isContent(r=r, row=1) self.execl.writeResult(1, 'pass') # print (set_so_keyword(app_id=20180829170725138653,sign='8C7DF610ECB03AEA0DA6AA64F6D8C572'))p_id=20180829170725138653,sign='8C7DF610ECB03AEA0DA6AA64F6D8C572'))
class UserTest(unittest.TestCase): def setUp(self): self.obj = Method() self.p = IsContent() self.log = MyLog() self.excel = OperationExcel() self.operJson = OperationJson() def isContent(self, r, row): self.assertEqual(r.status_code, 200) self.assertTrue(self.p.isContent(row=row, str2=r.text)) def test_user_01(self): '''获取个人信息''' r = self.obj.method(12) self.isContent(r, 12) self.excel.writeResult(12, 'pass') def test_user_02(self): '''获取菜单配置数据''' r = self.obj.method(13) self.isContent(r, 13) self.excel.writeResult(13, 'pass') def test_user_03(self): '''获取我的订单列表''' r = self.obj.method(14, data=self.operJson.getRequestsData(14)) self.isContent(r, 14) self.excel.writeResult(14, 'pass') order_sn = re.findall('order_sn":"(.+?)","', r.text) #利用正则表达式提取所有订单编号 writeDatafile(fileName='orderId.md', content=json.dumps(order_sn)) #序列化转为字符串写入 def test_user_04(self): '''订单详情页验证''' #利用循环依次取出每个订单号 for i in range(len(getOrdersn())): r = self.obj.method(15, data=setRelevance(row=15, orderSn=getOrdersn()[i])) self.isContent(r, 15) self.excel.writeResult(15, 'pass') def test_user_05(self): '''电子票夹验证''' r = self.obj.method(16) self.isContent(r, 16) self.excel.writeResult(16, 'pass') def test_user_06(self): '''我的卡包列表验证''' r = self.obj.method(17) self.isContent(r, 17) self.excel.writeResult(17, 'pass')
class Init(): def setUp(self): self.obj = Method() self.p = IsContent() self.excel = OperationExcel() def statusCode(self, r): """断言协议状态码和JSON 文件的关键字""" self.assertEqual(r.status_code, 200) self.assertEqual(r.json()['code'], 1) def isContent(self, r, row): '''断言业务状态码和参数预期结果是否一致''' self.statusCode(r=r) self.assertTrue(self.p.isContent(row=row, str2=r.text))
class HomeTest(unittest.TestCase): def setUp(self): self.obj = Method() self.p = IsContent() self.log = MyLog() self.excel = OperationExcel() def isContent(self, r, row): self.assertEqual(r.status_code, 200) self.assertTrue(self.p.isContent(row=row, str2=r.text)) def test_home_01(self): '''获取首页各类信息''' r = self.obj.method(6) self.isContent(r, 6) self.excel.writeResult(6, 'pass') def test_home_02(self): '''获取热门演出推荐列表''' r = self.obj.method(7) self.isContent(r, 7) self.excel.writeResult(7, 'pass') def test_home_03(self): '''获取巡演推荐列表''' r = self.obj.method(8) self.isContent(r, 8) self.excel.writeResult(8, 'pass') def test_home_04(self): '''获取首页楼层演出列表''' r = self.obj.method(9) self.isContent(r, 9) self.excel.writeResult(9, 'pass') def test_home_05(self): '''获取热门场馆列表''' r = self.obj.method(10) self.isContent(r, 10) self.excel.writeResult(10, 'pass') def test_home_06(self): '''为你推荐列表''' r = self.obj.method(11) self.isContent(r, 11) self.excel.writeResult(11, 'pass')
class LoginTest(unittest.TestCase): def setUp(self): self.obj=Method() self.p=IsContent() self.execl=OperationExcel() self.operationJson=OperationJson() self.log=MyLog() def isContent(self,r,row): self.assertEqual(r.status_code, 200) self.assertTrue(self.p.isContent(row=row,str2=r.text)) def test_login_01(self): '''正确的账号密码登录''' r = self.obj.post(1,data=setSo()) self.isContent(r,1) self.execl.writeResult(1,'pass') #测试结果写到excel #cookies= requests.utils.dict_from_cookiejar(r.cookies) #把cookies转为字典类型 #提取sessionid并写入文件中 writeDatafile(fileName='sessionid.md',content=r.cookies['juooo_sessionid']) def test_login_02(self): '''正确的账号错误的密码登录''' r=self.obj.post(2,data=setSo(password=1230)) self.isContent(r,2) self.execl.writeResult(2, 'pass') def test_login_03(self): '''错误的账号正确密码登录''' r=self.obj.post(3,data=setSo(username='******')) self.isContent(r,3) self.execl.writeResult(3, 'pass') def test_login_04(self): '''错误的账号错误的密码登录''' r=self.obj.post(4,data=setSo(username='******',password=123)) self.isContent(r,4) self.execl.writeResult(4, 'pass') def test_login_05(self): '''账号密码为空登录''' r=self.obj.post(5,data=setSo(username='',password='')) self.isContent(r,5) self.execl.writeResult(5, 'pass')
class LaGou(unittest.TestCase): # log = Log() def setUp(self): self.obj = Method() self.p = IsContent() self.execl = OperationExcel() self.operationJson = OperationJson() self.log = Log() def tearDown(self): pass def statusCode(self, r): self.assertEqual(r.status_code, 200) print(r.status_code) # print(r.json()['code']) # self.assertEqual(r.json ()['code'], 200) def isContent(self, r, row): self.statusCode(r=r) self.assertTrue(self.p.isContent(row=row, str2=r.text)) def test_post_001(self): """测试post接口-直接请求""" print("test_laGou_001方法执行") self.log.info("------测试post接口-直接请求:start!---------") # print(check_user(user=jp_user,name=18821768014)) "sign为空" r = self.obj.post(row=1, data=self.operationJson.getRequestsData(row=1)) print("test_laGou_001 is:", r.text) self.log.info("获取请求结果:%s" % r.text) self.isContent(r=r, row=1) self.execl.writeResult(1, 'pass') def test_post_002(self): print("test_laGou_002方法执行") "测试post接口-参数化请求" self.log.info("------测试post接口-参数化请求:start!---------") r = self.obj.post(row=1, data=set_so_keyword1(phone='18821768014')) print("test_laGou_002 is:", r.text) self.isContent(r=r, row=1) self.execl.writeResult(1, 'pass')
class Kuai8(unittest.TestCase): def setUp(self): self.obj=method() self.p=IsContent() self.excle=OpenationExcel() def isContent(self,r,row): # self.statusCode(r=r) self.assertTrue(self.p.isContent(row=row,str2=r.text)) def statusCode(self,r): self.assertEqual(r.status_code,200) self.assertEqual(r.json()['msg_num'],0) # def test_login_001(self): # r=self.obj.get(1) # list1=[] # user_ifo=r.json()['result'] # list1.append(user_ifo) # writeuser(json.dumps(list1)) # self.isContent(r=r, row=1) def test_login_001(self): r=self.obj.get(url=getUrl('18810037430')) print(r.json()) self.isContent(r=r,row=1) self.excle.writeReuslt(1,'pass') def test_login_002(self): r=self.obj.get(url=getUrl('188100374301')) self.isContent(r=r,row=2) print(r.json()) self.excle.writeReuslt(2,'pass') def test_like_001(self): data={} data['like']=1, data['smid']='X14zVGRHoZWDzJiXjw5ezciRKSnCSDFP' r=self.obj.post2(row=3,data=data) self.isContent(r=r,row=3) print(r.json()) self.excle.writeReuslt(3,'pass')
class LaGou(unittest.TestCase): def setUp(self): self.obj=Method() self.p=IsContent() self.execl=OperationExcel() self.operationJson=OperationJson() def statusCode(self,r): self.assertEqual(r.status_code, 200) self.assertEqual(r.json()['result_code'], 200) def isContent(self,r,row): self.statusCode(r=r) self.assertTrue(self.p.isContent(row=row,str2=r.text)) def test_laGou_001(self): '''测试1''' r = self.obj.post(row=1,data=self.operationJson.getRequestsData(1)) print ("test_laGou_001 is:", r.text) self.isContent(r=r,row=1) self.execl.writeResult(1,'pass')
class LaGou(unittest.TestCase): def setUp(self): self.obj = Method() self.p = IsContent() self.execl = OperationExcel() self.operationJson = OperationJson() def statusCode(self, r): # self.assertEqual(r.status_code, 200) self.assertEqual(r.json()['result_code'], 1006) def isContent(self, r, row): self.statusCode(r=r) self.assertTrue(self.p.isContent(row=row, str2=r.text)) def test_laGou_004(self): "sign为空" r = self.obj.post(row=3, data=set_so_keyword(app_id="20180829170725138653")) print("test_laGou_004 is:", r.text) self.isContent(r=r, row=3) self.execl.writeResult(3, 'pass')
class LaGou(unittest.TestCase): def setUp(self): self.obj=Method() self.p=IsContent() self.execl=OperationExcel() self.operationJson=OperationJson() # def statusCode(self,r): # # self.assertEqual(r.status_code, 200) # self.assertEqual(r.json()['result_code'], 401) def isContent(self,r,row): # self.statusCode(r=r) self.assertTrue(self.p.isContent(row=row,str2=r.text)) def test_laGou_001(self): '''测试1''' # r = self.obj.post(row=1,data=self.operationJson.getRequestsData(1)) r = self.obj.post (row=1, data=set_so_keyword (app_id='20180829170725138653', sign='8C7DF610ECB03AEA0DA6AA64F6D8C572')) print ("test_laGou_001 is:", r.text) self.assertEqual(r.json()['result_code'], 200) self.isContent(r=r,row=1) self.execl.writeResult(1,'pass') def test_laGou_002(self): '''错误测试''' r = self.obj.post(row=2,data=self.operationJson.getRequestsData(2)) self.assertEqual(r.json()['result_code'], 403) print ("test_laGou_001 is:", r.text) self.isContent (r=r, row=2) self.execl.writeResult (2, 'pass') def test_laGou_004(self): "sign为空" r = self.obj.post(row=3,data=set_so_keyword(app_id=201808291707251386534444)) print ("test_laGou_002 is:", r.text) self.assertEqual(r.json()['result_code'], 403) self.isContent (r=r, row=3) self.execl.writeResult (3,'pass')
class Login(unittest.TestCase): def setUp(self): self.methon = WebMethon() self.config = Config() self.excel = OperationExcel() self.pm = PublicMethod() self.operationJson = OperationJson() self.iscontent = IsContent() def tearDown(self): print('测试结束') def test_Login_001(self): ''' 登陆DDOU:/api/login :return: ''' r = requests.post(url=self.config.getUrl() + self.excel.get_Url(1), json=self.operationJson.getRequestsData(1)) print(r.json()) self.assertTrue(r.json()['msg'], "成功") self.assertTrue(self.iscontent.isContent(1, r.text))
class Login(unittest.TestCase): def setUp(self): self.methon = WebMethon() self.config = Config() self.excel = OperationExcel() self.pm = PublicMethod() self.operationJson = OperationJson() self.iscontent = IsContent() def tearDown(self): pass def test_Login_001(self): ''' 登陆大桶大后台系统:/Account/Login :return: ''' r = self.methon.post(0, 1) self.assertTrue(r.json()['IsSuccess'], True) self.assertTrue(self.iscontent.isContent(1, r.text)) #将登陆成功后得token写入到文件中 self.pm.writeFile('data', 'login', 'token', r.json()['Data']['token'])
def setUp(self): self.obj = Method() self.p = IsContent() self.excel = OperationExcel()
def setUp(self): self.obj=method() self.p=IsContent() self.excle=OpenationExcel()
def setUp(self): self.obj = Method() self.p = IsContent() self.log = MyLog() self.excel = OperationExcel() self.operJson = OperationJson()
class Admin(unittest.TestCase): def setUp(self): self.obj = Method() self.p = IsContent() self.excel = OperationExcel() def statusCode(self, r): """断言协议状态码和JSON 文件的关键字""" self.assertEqual(r.status_code, 200) self.assertEqual(r.json()['code'], 1) def isContent(self, r, row): '''断言业务状态码和参数预期结果是否一致''' self.statusCode(r=r) self.assertTrue(self.p.isContent(row=row, str2=r.text)) def test_admin_001(self): """登录接口""" r = self.obj.post(data=Login('PWD@15618824739', 111111, grant_type='mall', row=2), row=2) data = r.json() with open("../data/token.json", "w") as f: header = { 'Authorization': 'Bearer ' + data['access_token'], 'Content-Type': 'application/json;charset=UTF-8' } json.dump(header, f) print(r.text) def test_admin_002(self): """供应商信息搜索接口,并将id写入到supplierid文件中""" r = self.obj.get(params=detail(1, 50, row=3), row=3) print(r.text) supplierid = '' for i in range(0, 50): supplierid = str( r.json()['data']['records'][i]['id']) + ',' + supplierid writesupplierID(supplierid) self.assertTrue(self.p.isContent(str2=r.text, row=2)) self.isContent(r=r, row=2) self.excel.writeResult(row=2, content='pass') # @unittest.skip('pass') def test_admin_003(self): """新增日志""" r = self.obj.post(data=json.dumps( Logs(content='自动化测试用例', logType='QR', overstockId=120, row=3)), row=3) print(r.text) self.isContent(r=r, row=3) self.excel.writeResult(row=3, content='pass') # @unittest.skip('pass') def test_admin_004(self): '''删除供应商接口''' # list=getSupplierid().split(",") # supplierid=list[2] r = self.obj.delete(url=geturl(row=4, id=soSupplierid()), row=4) print('supplierid:', soSupplierid()) print(r.text) self.assertTrue(self.p.isContent(row=4, str2=r.text)) self.excel.writeResult(row=4, content='pass') # @unittest.skip('pass') def test_admin_005(self): '''添加供应商信息''' r = self.obj.post(data=add_supplier(phone=15616624736, id=None, row=5), row=5) print(r.text) def test_admin_006(self): '''修改供应商信息''' r = self.obj.put(add_supplier(phone=15614597456, id=47, row=6), row=6) print(r.text) def test_admin_007(self): '''修改供应商临时周期''' r = self.obj.put(updateTime(id=soSupplierid(), cycleType='MONTH', updateCycle=10, row=7), row=7) print(r.text) # @unittest.skip('pass') def test_admin_008(self): '''分配''' r = self.obj.post(distributeSu(operatingId=14, list=[40, 41, 43, 45], row=8), row=8) print(r.text) # @unittest.skip('pass') def test_admin_009(self): '''更新供应商的呆料''' r = self.obj.put(url=geturl(id=62, row=9), row=9) print(r.text) # @unittest.skip('pass') def test_admin_10(self): '''类目列表''' r = self.obj.get(row=10) print(r.text) # @unittest.skip('pass') def test_admin_11(self): '''类目保存''' r = self.obj.post(category(name='test-005', parentId=5, sort=1, row=11), row=11) print(r.text) # @unittest.skip('pass') def test_admin_12(self): '''类目修改''' r = self.obj.put(category(name='test-3', parentId=0, sort=1, id=2, status='Y', row=11), row=11) print(r.text) # @unittest.skip('pass') def test_admin_13(self): '''估价单列表''' r = self.obj.get(params=detail(page=1, pageSize=10, row=13), row=13) print(r.text) evaluationid = '' for i in range(0, 20): evaluationid = str( r.json()['data']['records'][i]['id']) + ',' + evaluationid writesupplierID(evaluationid) @unittest.skip('pass') def test_admin_14(self): pass # '''新增估价单''' #@unittest.skip('pass') def test_admin_15(self): '''估价单详情''' r = self.obj.get(url=geturl(id=20, row=15), row=15) print(r.text) # @unittest.skip('pass') def test_admin_16(self): '''删除估价单''' r = self.obj.delete(geturl(id=40, row=16), row=16) print(r.text) # @unittest.skip('pass') def test_admin_17(self): '''确认估价''' r = self.obj.patch(url=geturl(id=57, row=17), row=17) print(r.text) # @unittest.skip('pass') def test_admin_18(self): '''重新爬取''' r = self.obj.get(url=geturl(id=55, row=18), row=18) print(r.text) # @unittest.skip('pass') def test_admin_19(self): '''下载估价单''' r = self.obj.get(url=geturl(id=55, row=19), row=19) print(r.text) @unittest.skip('pass') def test_admin_20(self): '''上传指导价''' pass # @unittest.skip('pass') def test_admin_21(self): '''生成呆料单''' r = self.obj.post(data=evaOverstock(address='南京', delivery="CN", evaluateId=54, factoryId=31, invType='TL', name='测试', premium='2.3', isRfq='Y', row=21), row=21) print(r.text) def test_admin_22(self): '''修正估价价格''' r = self.obj.patch(data=overStockpart(partsId=1370, updatePrice=1.3, row=22), row=22) print(r.text) def test_admin_23(self): '''删除选中物料''' r = self.obj.delete(url=partList(id=39, partsIds=[1318, 1319, 1321, 1320], row=23), row=23) print(r.text) def test_admin_24(self): '''一键删除冷门料''' r = self.obj.delete(url=geturl(id=55, row=24), row=24) print(r.text) @unittest.skip('pass') def test_admin_25(self): pass # '''上传出价''' # r = self.obj.delete(url=geturl(id=55, row=25), row=25) # print(r.text) def test_admin_26(self): '''报价预览''' r = self.obj.get(url=geturl(id=132, row=26), row=26) print(r.text) def test_admin_27(self): '''下载出价表格''' r = self.obj.get(url=geturl(id=132, row=27), row=27) print(r.text) def test_admin_28(self): '''标记删除|取消标记''' r = self.obj.patch(data=markId(id=11707, status='Y', row=28), row=28) print(r.text) def test_admin_29(self): '''预览生成订单----D''' r = self.obj.post(url=geturl(id=132, row=29), data=overOrder(customerId=85, entityId=[25524, 22525, 25526], row=29), row=29) print(r.text) def test_admin_30(self): '''修改原表----D''' r = self.obj.patch(url=geturl(id=205, row=30), data=partprice(partId=11707, row=30), row=30) print(r.text) def test_admin_31(self): '''删除日志''' r = self.obj.delete(url=geturl(id=424, row=31), row=31) print(r.text) def test_admin_32(self): '''查看沟通日志''' r = self.obj.get(url=geturl(id=205, row=32), row=32) print(r.text) def test_admin_33(self): '''呆料单列表''' r = self.obj.get(params=detail(page=1, pageSize=100, row=33), row=33) print(r.text) def test_admin_34(self): '''新增呆料单----D''' r = self.obj.post(data=evaOverstock(address="", delivery="HK", factoryId=15, invType="ZB", name="这是自动化上传的单子", isRfq="N", row=34), row=34) print(r.text) def test_admin_35(self): '''呆料单编辑详情''' r = self.obj.get(url=geturl(id=205, row=35), row=35) print(r.text) def test_admin_36(self): '''编辑呆料单----D''' r = self.obj.post(url=geturl(id=205, row=36), data=evaOverstock(address="苏州", delivery="HK", factoryId=92, invType="TL", name="这是自动化上传的单子", id=205, isRfq='N', row=36), row=36) print(r.text) def test_admin_37(self): '''删除呆料单''' r = self.obj.delete(url=geturl(id=205, row=37), row=37) print(r.text) def test_admin_38(self): '''下载呆料单原表''' r = self.obj.get(url=geturl(id=215, row=38), row=38) print(r.text) def test_admin_39(self): '''工厂(供应商)下拉框''' r = self.obj.get(params=factorySO(keyword="上海", row=39), row=39) print(r.text) def test_admin_40(self): '''呆料单列表-更多''' r = self.obj.get(params=detail(page=1, pageSize=100, row=40), row=40) print(r.text) def test_admin_41(self): '''更新状态(上架、下架)''' r = self.obj.patch(data=overStatus(id=215, status="N", row=41), row=41) print(r.text) def test_admin_42(self): '''下载呆料模板''' r = self.obj.get(params=None, url=None, row=42) print(r.text) def test_admin_43(self): '''置顶、取消置顶''' r = self.obj.patch(overStatus(id=214, status='Y', row=43), row=43) print(r.text) def test_admin_44(self): '''品牌列表,有分页''' r = self.obj.get(detail(page=1, pageSize=100, key='HPV', row=44), row=44) print(r.text) def test_admin_45(self): '''保存''' r = self.obj.post(brand(linkIds=4063, shortName=100, name='HPV', row=45), row=45) print(r.text) def test_admin_46(self): '''修改''' r = self.obj.post(brand(linkIds=4063, shortName=100, name='CVB', id=4063, row=46), row=46) print(r.text) def test_admin_47(self): '''删除''' r = self.obj.delete(geturl(id=4810, row=47), row=47) print(r.text) def test_admin_48(self): '''品牌列表无分页''' r = self.obj.get(row=48) print(r.text) def test_admin_49(self): '''客户信息搜索''' r = self.obj.get(params=detail(page=1, pageSize=100, key="上海", row=49), row=49) print(r.text) def test_admin_50(self): '''添加客户信息''' r = self.obj.post(data=customerAdd(company="sisi-0023", name="mumu-0023", phone=15623145698, row=50), row=50) print(r.text) def test_admin_51(self): '''修改客户信息''' r = self.obj.put(data=customerAdd(company="sisi-0023", name="tes-001", phone=15618822221, row=51, id=83), row=51) print(r.text) def test_admin_52(self): '''客户详情''' r = self.obj.get(url=geturl(id=83, row=52), row=52) print(r.text) def test_admin_53(self): '''删除''' r = self.obj.delete(url=geturl(id=83, row=53), row=53) print(r.text) def test_admin_54(self): '''客户为新的标识取消''' r = self.obj.delete(url=partList(id=128, partsIds=4, row=54), row=54) print(r.text) def test_admin_55(self): '''分配''' r = self.obj.post(data=distributeSu(operatingId=128, list=[128, 117, 114, 113], row=55), row=55) print(r.text) def test_admin_56(self): '''客户信息下拉框''' r = self.obj.get(params=detail(page=1, pageSize=10, key='上海', row=56), row=56) print(r.text) def test_admin_57(self): '''客户信息下拉框''' r = self.obj.get(row=57) print(r.text) def test_admin_58(self): '''数据中心id号(58-71)''' r = self.obj.get(orderover(cycleType='weeks', endTime='2019-06-23 23:59:59', startTime='2019-06-17 23:59:59', type='customer', row=58), row=70) print(r.text) def test_admin_59(self): '''数据字典列表有分页''' r = self.obj.get(detail(page=1, pageSize=100, row=72), row=72) print(r.text) def test_admin_60(self): '''添加字典''' r = self.obj.post(data=dict(flagName="客户类型", flagType="CUSTOMERTYPE", kvList={ "LDS": "料单商", "MUX": "目录型" }, row=73), row=73) print(r.text) def test_admin_61(self): '''修改字典的键值''' r = self.obj.put(data=dictValue(id=101, dictValue="cszy", row=74), row=74) print(r.text) def test_admin_62(self): '''删除''' r = self.obj.delete(url=geturl(id=101, row=75), row=75) print(r.text) def test_admin_63(self): '''数据字典列表无分页''' r = self.obj.get(row=76) print(r.text) def test_admin_64(self): '''数据字典类型列表''' r = self.obj.get(row=77) print(r.text) # def test_admin_65(self): # '''素材列表''' # r = self.obj.get(params=detail(page=1,pageSize=100,row=72),row=78) # print(r.text) def test_admin_66(self): '''活动、供应商、合作伙伴''' r = self.obj.get(params=detail(page=1, pageSize=2, row=72), row=82) print(r.text) def test_admin_67(self): '''添加banner、活动、供应商、合作伙伴---D''' r = self.obj.post(data=friend(link="javascript:;", materialFile="", row=83), row=83) print(r.text) def test_admin_68(self): '''删除banner、活动、供应商、合作伙伴''' r = self.obj.delete(url=geturl(id=66, row=84), row=84) print(r.text) # def test_admin_69(self): # '''vadas动态''' # r = self.obj.get(params=detail(pageSize=100,page=1,row=72), row=84) # print(r.text) # # # def test_admin_70(self): # '''''' # r = self.obj.post(data=News(content='这是自动化测试',source='',row=86,title='这是自动化测试'), row=86) # print(r.text) def test_admin_89(self): '''编辑banner、活动、供应商、合作伙伴''' r = self.obj.post(data=friend(id=25, link='/pool', name='测试', type="BA", row=89), row=89) print(r.text) def test_admin_90(self): '''用户反馈列表''' r = self.obj.get(params=detail(page=1, pageSize=100, row=72), row=90) print(r.text) def test_admin_91(self): '''咨询反馈红点''' r = self.obj.get(row=91) print(r.text) def test_admin_92(self): '''取消咨询反馈红点''' r = self.obj.post(data=feedbackType(type='SQGYS', row=92), row=92) print(r.text) def test_admin_93(self): '''用户呆料列表''' r = self.obj.get(params=detail(page=1, pageSize=100, row=72), row=93) print(r.text) def test_admin_94(self): '''更新状态''' r = self.obj.post(url=geturl(id=1, row=72), row=94) print(r.text) def test_admin_95(self): '''申请供应商列表''' r = self.obj.get(params=detail(page=1, pageSize=100, row=72), row=95) print(r.text) def test_admin_96(self): '''更新状态''' r = self.obj.post(url=geturl(id=53, row=96), data=None, row=96) print(r.text) def mcc(self): '''MCC物料列表''' r = self.obj.get(params=detail(page=1, pageSize=100, row=72), row=110) print(r.text)
def setUp(self): self.obj = Method() self.p = IsContent() self.execl = OperationExcel() self.operationJson = OperationJson()
class Xiangmuguanli(unittest.TestCase): def setUp(self): self.obj = Method() self.p = IsContent() self.opexcel = OperationExcel() def statusCode(self, r): self.assertEqual(r.status_code, 200) def isContent(self, r, row): self.statusCode(r=r) self.assertTrue(self.p.isContent(row=row, str2=r.text)) def test_001_insert(self): '''项目管理:新增测试''' r = self.obj.post_yuanshi(row=1) # self.statusCode(r=r) # self.assertTrue(self.p.isContent(row=1,str2=r.text)) # 上面两句断言封装一个方法 self.isContent(r=r, row=1) # 把结果写到表格里 self.opexcel.writeResult(row=1, content='pass') # print(r.text) # def test_001_insert_updatename(self): # '''项目管理:请求数据的重新赋值''' # r = self.obj.post_update(row=1, data=updateData(name='电风扇')) # self.isContent(r=r, row=1) # def test_002_chaxun_str(self): # r = self.obj.post_yuanshi(2) # self.isContent(r=r, row=2) # for i in range(0, 10): # if r.json()['data'][i]['name'] == '搜索': # id = r.json()['data'][i]['id'] # writePositionId(id) def test_002_chaxun_list(self): '''项目管理:查询测试''' list1 = [] r = self.obj.post_yuanshi(2) self.isContent(r=r, row=2) for i in range(0, 10): if r.json()['data'][i]['name'] == '搜索': id = r.json()['data'][i]['id'] list1.append(id) # print(list1) # print(type(list1)) writePositionId(json.dumps(list1)) def test_003_upate(self): '''项目管理:修改测试''' r = self.obj.put(row=3) print(r.url) self.isContent(r=r, row=3) def test_004_delete(self): '''项目管理:删除测试''' r = self.obj.delete(row=4) self.isContent(r=r, row=4)