def test_AdminGet02(self): """验证创建成功后获取管理员信息是否正确""" aid, account = OpenPlatformCommon.getaid(self.mid) date = time.strftime('%Y-%m-%d', time.localtime(time.time())) res = self.client.sendbyurl(aid) res_result = JMESPathExtractor().extract(query='success', body=res.text) res_aid = JMESPathExtractor().extract(query='data.id', body=res.text) res_mid = JMESPathExtractor().extract(query='data.mId', body=res.text) res_loginaccount = JMESPathExtractor().extract( query='data.loginAccount', body=res.text) res_mobile = JMESPathExtractor().extract(query='data.mobile', body=res.text) res_position = JMESPathExtractor().extract(query='data.position', body=res.text) res_realname = JMESPathExtractor().extract(query='data.realName', body=res.text) res_createtime = JMESPathExtractor().extract(query='data.createTime', body=res.text) res_state = JMESPathExtractor().extract(query='data.state', body=res.text) res_type = JMESPathExtractor().extract(query='data.type', body=res.text) msg = '\n请求地址:' + res.url + '\n请求数据:' + aid + '\n返回结果:' + res.text self.assertEqual('true', str(res_result).lower(), msg=msg) self.assertEqual(self.mid, res_mid, msg=msg) self.assertEqual(aid, res_aid, msg=msg) self.assertEqual(account, res_loginaccount, msg=msg) self.assertEqual('None', str(res_mobile), msg=msg) self.assertEqual('', str(res_position), msg=msg) self.assertEqual('', str(res_realname), msg=msg) self.assertEqual('1', str(res_state), msg=msg) self.assertEqual('1', str(res_type), msg=msg) self.assertIn(date, str(res_createtime), msg=msg)
def test_AdminGet01(self): """简单验证获取管理员信息接口容错""" datas = ExcelReader(self.excel, sheet='GetAdmin').data for d in range(0, len(datas)): if datas[d]['is_execute'] == 'N': continue else: with self.subTest(data=datas[d]['CaseNo'] + datas[d]['describe']): self.setUp() # logger.debug(datas[d]) expect = datas[d]['expect_code'] casename = str(datas[d]['describe']) caseNo = str(datas[d]['CaseNo']) #请求的参数剔除期望值列、是否执行列、描述列、用例编号列 datas[d].pop('expect_code') datas[d].pop('is_execute') datas[d].pop('describe') datas[d].pop('CaseNo') if datas[d]['id'] == '{aid}': datas[d]['id'] = OpenPlatformCommon.getaid(self.mid)[0] res = self.client.sendbyurl(datas[d]['id']) # resultlist =[caseNo,casename,params,expect,res.text] # resultdata.qppend(resultlist) # logger.debug(res.text) result = JMESPathExtractor().extract(query='success', body=res.text) message = JMESPathExtractor().extract(query='message', body=res.text) msg = '\n请求地址:' + res.url + '\n返回结果:' + res.text self.assertEqual(expect, str(result).lower(), msg=msg) self.assertNotIn('未知错误', str(message), msg=msg) self.tearDown()