def queryInfoByAccessNumber(self, accessNum): '''根据号码查询用户信息''' logger.info("开始参数化......") params = { "ACCESS_NUM": accessNum, #需要参数化 accessNum "svcName": "OrderCentre.enterprise.IMemberUserInfoQuerySV.queryInfoByAccessNumber" } print("接口名:" + params['svcName']) print("拼装入参完成,接口完整入参:" + json.dumps(params)) logger.info("接口名:" + params['svcName']) logger.info("拼装商品订购入参完成,接口完整入参:" + json.dumps(params)) logger.info("接口名:" + params['svcName']) logger.info("开始构建请求......" + "\n") intf_res = self.session.post(url=rc.get_interface_url("url_interface"), headers=h, data=params) print("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("处理接口返回数据....") d_intf_res = json.loads(intf_res.content.decode(encoding='utf-8')) x_resultcode = dict_get(d_intf_res, 'X_RESULTCODE', None) if x_resultcode == '0': result = dict_get(d_intf_res, 'DATAS', None) access_num = result[0]['ACCESS_NUM'] subscriber_inst_id = result[0]['SUBSCRIBER_INS_ID'] print("接口处理成功,受理号码为:" + access_num + " 用户实例号:" + subscriber_inst_id) return subscriber_inst_id
def queryEnterpriseByGroupId(self, groupId): '''根据集团编码查询集团信息''' params = { "GROUP_ID": groupId, #需要参数化 accessNum "svcName": "CustomerCentre.custmgr.IEntQuerySV.queryEnterpriseByGroupId" } logger.info("接口名:" + params['svcName']) logger.info("拼装商品订购入参完成,接口完整入参:" + json.dumps(params)) print("拼装入参完成,接口完整入参:" + json.dumps(params)) logger.info("接口名:" + params['svcName']) logger.info("开始构建请求......" + "\n") intf_res = self.session.post(url=rc.get_interface_url("url_interface"), headers=h, data=params) print("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) d_intf_res = json.loads(intf_res.content.decode(encoding='utf-8')) x_resultcode = dict_get(d_intf_res, 'X_RESULTCODE', None) if x_resultcode == '0': result = dict_get(d_intf_res, 'DATAS', None) logger.info("查询成功,处理结果result:" + json.dumps(result, ensure_ascii=False)) cust_id = result[0]['ORGA_ENTERPRISE_ID'] group_id = result[0]['GROUP_ID'] groupName = result[0]['GROUP_NAME'] print("查询成功,集团编码为:" + group_id + " 集团名称:" + groupName + ", cust_id =" + cust_id) return cust_id
def ImsMebStopOrOpen(self, imsNum, operCode): '''IMS号码停开机接口''' params = { "IMS_USER_STATE": operCode, #02停机 01 开机 "ACCESS_NUM": imsNum, # 需要参数化 "svcName": "OrderCentre.enterprise.IImsCloseGrpMainOperateSV.commitUserSvcOpen" } logger.info("接口名:" + params['svcName']) logger.info("拼装商品订购入参完成,接口完整入参:" + json.dumps(params)) print("拼装入参完成,接口完整入参:" + json.dumps(params)) logger.info("接口名:" + params['svcName']) logger.info("开始构建请求......" + "\n") intf_res = self.session.post(url=rc.get_interface_url("url_interface"), headers=h, data=params) print("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("处理接口返回数据....") d_intf_res = json.loads(intf_res.content.decode(encoding='utf-8')) x_resultcode = dict_get(d_intf_res, 'X_RESULTCODE', None) if x_resultcode == '0': flowid = dict_get(d_intf_res, 'DATAS', None) logger.info(" 受理成功,业务交互流水号:" + flowid) print(" 受理成功,业务交互流水号:" + flowid) else: x_resultInfo = dict_get(d_intf_res, 'x_resultinfo', None) print("受理异常,错误信息:" + x_resultInfo) logger.info("受理异常,错误信息:" + x_resultInfo) return x_resultInfo
def test_IntfChgprodstatus(self, dic): '''【接口】停开机业务受理测试''' logger.info("开始参数化......") index = int(dic.get('NO')) accessNum = str(dic.get('ACCESS_NUM')) logger.info("测试号码:" + accessNum) busicode = dic.get('BUSICODE') logger.info("停开机业务类型:" + busicode) params = { "svcName": 'OrderCentre.person.IChangeProdStaOperateSV.changeProdStatus', "ACCESS_NUM": accessNum, "BUSI_ITEM_CODE": busicode } logger.info("params参数化以后的接口入参:" + json.dumps(params)) print("params参数化以后的接口入参:" + json.dumps(params)) # logger.info("开始接口测试开始,接口名为"+svcname +" 接口参数是:" + json.dumps(params)) logger.info('开始执行第{}个用例,接口入参:{}'.format(index, dic)) logger.info("开始构建请求......" + "\n") intf_url = rc.get_interface_url("url_interface") logger.info("接口测试地址:" + intf_url) intf_res = self.session.post(url=intf_url, headers=h, data=params) logger.info("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) d_intf_res = json.loads(intf_res.content.decode(encoding='utf-8')) x_resultcode = dict_get(d_intf_res, 'x_resultcode', None) if x_resultcode == '0': flowid = dict_get(d_intf_res, 'flowId', None) access_num = dict_get(d_intf_res, 'ACCESS_NUM', None) x_resultinfo = dict_get(d_intf_res, 'X_RESULTINFO', None) logger.info("接口处理成功,受理号码为:" + access_num + " 订单交互流水号:" + flowid) print("接口处理成功,受理号码为:" + access_num + " 订单交互流水号:" + flowid) logger.info("开始写入xls数据......") write_xlsBycolName_append(file=self.file, row=index, colName='RESULT_INFO', value=x_resultinfo) write_xlsBycolName_append(file=self.file, row=index, colName='FLOWID', value=flowid) logger.info("测试结果写入xls成功......") else: x_resultinfo = dict_get(d_intf_res, 'x_resultinfo', None) logger.info("接口调用失败,错误信息:" + x_resultinfo) print("接口处理错误信息:" + x_resultinfo) logger.info("开始写入xls数据......") write_xlsBycolName_append(file=self.file, row=index, colName='RESULT_INFO', value=x_resultinfo) logger.info("测试结果写入xls成功......") self.assertEqual(x_resultcode, '0')
def test_ChgUserPwd(self, dic): logger.info("开始参数化......") index = int(dic.get('NO')) logger.info('开始执行第{}个用例,接口入参:{}'.format(index, dic)) accessNum = str(dic.get('ACCESS_NUM')) logger.info("测试号码:" + accessNum) newPassword = dic.get('NEW_PWD') params = { "IS_INTERFACE": "1", "CHANGE_TYPE": "1", "ACCESS_NUM": accessNum, "NEW_PASSWORD": newPassword, "svcName": "OrderCentre.person.ISubscriberOperateSV.changeSubscriberPassword" } logger.info("开始构建请求......" + "\n") intf_url = rc.get_interface_url("url_interface") logger.info("接口测试地址:" + intf_url) intf_res = self.session.post(url=intf_url, headers=h, data=params) logger.info("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("处理接口返回数据....") d_intf_res = json.loads(intf_res.content.decode(encoding='utf-8')) x_resultcode = dict_get(d_intf_res, 'X_RESULTCODE', None) if x_resultcode == '0': flowid = dict_get(d_intf_res, 'flowId', None) logger.info("接口处理成功,受理号码为:{},订单交互流水号:{}".format(accessNum, flowid)) print("接口处理成功,受理号码为:{},订单交互流水号:{}".format(accessNum, flowid)) logger.info("开始写入结果xls数据......") write_xlsBycolName_append(file=self.file, row=index, colName='FLOWID', value=flowid) logger.info("测试结果写入xls成功......") else: x_resultinfo = dict_get(d_intf_res, 'x_resultinfo', None) logger.info("接口处理失败,错误信息:{}".format(x_resultinfo)) print("接口处理错误信息:" + x_resultinfo) logger.info("开始写入xls数据......") write_xlsBycolName_append(file=self.file, row=index, colName='RESULT_INFO', value=x_resultinfo) logger.info("测试结果写入xls成功......")
def test_modifyRealChkInfo(self,dic): logger.info("开始参数化......") index = int(dic.get('NO')) logger.info('开始执行第{}个用例,接口入参:{}'.format(index,dic)) accessNum = str(dic.get('ACCESS_NUM')) logger.info("测试号码:"+accessNum) custId = str(dic.get('CUST_ID')) IdenId= str(dic.get('IDEN_ID')) custName = GenTestData().create_CustName() #随机生成姓名 psptId = GenTestData().Create_Idcard() #随机身份证号码 # logger.info('证件号码:{}'.format(psptId)) write_xlsBycolName_append(file=file,row=index,colName='NEWCUSTNAME',value=custName) write_xlsBycolName_append(file=file,row=index,colName='NEW_IDENID',value=psptId) params = { "CUSTINFO_PSPT_ID": psptId, # 证件号先写死这个 "SERIAL_NUMBER": accessNum, "PARTY_ID": custId, "CUSTINFO_PSPT_ADDRESS": "测试地址测试地址11", "ACCESS_NUM": accessNum, "CUSTINFO_PSPT_TYPE_CODE": "10000000", #10000000表示身份证 "svcName": "CustomerCentre.custmgr.IPersonOperateSV.modifyRealNameCheckInInfo", "IDEN_ID": IdenId, "CUST_ID": accessNum, "CUSTINFO_CUST_NAME": custName } logger.info("开始构建请求......"+"\n") intf_url = rc.get_interface_url("url_interface") logger.info("接口测试地址:" + intf_url ) intf_res = self.session.post(url=intf_url,headers = h, data = params) logger.info("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("处理接口返回数据....") d_intf_res = json.loads(intf_res.content.decode(encoding='utf-8')) x_resultcode = dict_get(d_intf_res, 'X_RESULTCODE', None) if x_resultcode == '0': flowid = dict_get(d_intf_res, 'INTACT_ID', None) logger.info("接口处理成功,受理号码为:{},订单交互流水号:{}".format(accessNum,flowid)) print("接口处理成功,受理号码为:{},订单交互流水号:{}".format(accessNum,flowid)) logger.info("开始写入结果xls数据......") write_xlsBycolName_append(file=self.file, row=index,colName='FLOWID', value=flowid) logger.info("测试结果写入xls成功......") else: x_resultinfo = dict_get(d_intf_res, 'x_resultinfo', None) logger.info("接口处理失败,错误信息:{}".format(x_resultinfo)) print("接口处理错误信息:" + x_resultinfo) logger.info("开始写入xls数据......") write_xlsBycolName_append(file=self.file, row=index,colName='RESULT_INFO', value=x_resultinfo) logger.info("测试结果写入xls成功......")
def queryOfferInstByCustIdAndOfferId(self, custId, offerId): '''根据集团客户标识和主商品OFFERID查询已订购商品''' #先查询集团客户信息获取custId # custId = self.queryEnterpriseByGroupId('8743603478') #返回custId params = { "CUST_ID": custId, #参数化 custId 由上个接口返回 "OFFER_ID": int(offerId), "svcName": "OrderCentre.enterprise.IUmOfferQuerySV.queryOfferInstanceByCustIdAndOfferId" } logger.info("接口名:" + params['svcName']) logger.info("拼装商品订购入参完成,接口完整入参:" + json.dumps(params)) print("拼装入参完成,接口完整入参:" + json.dumps(params)) logger.info("接口名:" + params['svcName']) logger.info("开始构建请求......" + "\n") intf_res = self.session.post(url=rc.get_interface_url("url_interface"), headers=h, data=params) print("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) d_intf_res = json.loads(intf_res.content.decode(encoding='utf-8')) x_resultcode = dict_get(d_intf_res, 'X_RESULTCODE', None) if x_resultcode == '0': result = dict_get(d_intf_res, 'DATAS', None) logger.info("查询成功,处理结果result:" + json.dumps(result, ensure_ascii=False)) for i in range(len(result)): print("已订购的集团商品列表" + str(i) + ":\n" + json.dumps(result[i], ensure_ascii=False)) offerId = result[i]['OFFER_ID'] offername = result[i]['OFFER_NAME'] grp_inst_id = result[i]['SUBSCRIBER_INS_ID'] offerInstId = result[i]['OFFER_INS_ID'] logger.info("订购的集团商品ID:" + offerId) logger.info("订购的集团商品名称:" + offername) logger.info("订购的集团用户ID:" + grp_inst_id) logger.info("订购的集团商品实例ID:" + offerInstId) print("订购的集团商品ID:" + offerId) print("订购的集团商品名称:" + offername) print("订购的集团用户ID:" + grp_inst_id) print("订购的集团商品实例ID:" + offerInstId) return json.dumps(result, ensure_ascii=False) else: x_resultInfo = dict_get(d_intf_res, 'x_resultinfo', None) return x_resultInfo
def querySubscriberRel(self, accessNum, rel_type): '''根据用户实例查询订购的集团商品''' userId = self.queryInfoByAccessNumber(accessNum) params = { "REL_SUBSCRIBER_INS_ID": userId, # 需要参数化 userId "SUBSCRIBER_REL_TYPE": rel_type, # 需要参数化 "ACCESS_NUM": accessNum, "svcName": "OrderCentre.enterprise.IUmSubscriberRelQuerySV.querySubscriberRelByRelSubInsIdAndSubRelType" } logger.info("接口名:" + params['svcName']) logger.info("拼装商品订购入参完成,接口完整入参:" + json.dumps(params)) print("拼装入参完成,接口完整入参:" + json.dumps(params)) logger.info("接口名:" + params['svcName']) logger.info("开始构建请求......" + "\n") intf_res = self.session.post(url=rc.get_interface_url("url_interface"), headers=h, data=params) print("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("处理接口返回数据....") d_intf_res = json.loads(intf_res.content.decode(encoding='utf-8')) x_resultcode = dict_get(d_intf_res, 'X_RESULTCODE', None) if x_resultcode == '0': result = dict_get(d_intf_res, 'DATAS', None) print("查询结果:" + json.dumps(result, ensure_ascii=False)) logger.info("查询成功,处理结果result:" + json.dumps(result, ensure_ascii=False)) for i in range(len(result)): grp_inst_id = result[i]['SUBSCRIBER_INS_ID'] accessnum = result[i]['REL_ACCESS_NUM'] reltype = result[i]['SUBSCRIBER_REL_TYPE'] logger.info("订购的集团用户ID:" + grp_inst_id) print("成员号码:" + accessnum + " 订购的集团用户ID:" + grp_inst_id + " 关系类型:" + reltype) return json.dumps(result, ensure_ascii=False) # 把订购关系返回 else: x_resultInfo = dict_get(d_intf_res, 'x_resultinfo', None) return x_resultInfo
def queryOfferInstByAccessNumber(self, accessNum): '''根据手机号码查询订购的集团商品''' userId = self.queryInfoByAccessNumber(accessNum) params = { "SUBSCRIBER_INS_ID": userId, "svcName": "OrderCentre.enterprise.IUmOfferQuerySV.queryOfferInstanceByMebSubscriberInsId" } logger.info("接口名:" + params['svcName']) logger.info("拼装商品订购入参完成,接口完整入参:" + json.dumps(params)) print("拼装入参完成,接口完整入参:" + json.dumps(params)) logger.info("接口名:" + params['svcName']) logger.info("开始构建请求......" + "\n") intf_res = self.session.post(url=rc.get_interface_url("url_interface"), headers=h, data=params) print("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("处理接口返回数据....") d_intf_res = json.loads(intf_res.content.decode(encoding='utf-8')) x_resultcode = dict_get(d_intf_res, 'X_RESULTCODE', None) # x_resultinfo = dict_get(d_intf_res, 'X_RESULTINFO', None) if x_resultcode == '0': result = dict_get(d_intf_res, 'DATAS', None) print("查询结果:" + json.dumps(result, ensure_ascii=False)) logger.info("查询成功,处理结果result:" + json.dumps(result, ensure_ascii=False)) for i in range(len(result)): print("已订购的集团商品列表" + str(i) + ":\n" + json.dumps(result[i], ensure_ascii=False)) offername = result[i]['OFFER_NAME'] grp_inst_id = result[i]['SUBSCRIBER_INS_ID'] logger.info("订购的集团商品名称:" + offername) logger.info("订购的集团用户ID:" + grp_inst_id) print("订购的集团商品名称:" + offername) print("订购的集团用户ID:" + grp_inst_id) return json.dumps(result, ensure_ascii=False) #把订购的集团商品实例列表返回 else: x_resultInfo = dict_get(d_intf_res, 'x_resultinfo', None) return x_resultInfo
def test_ChgMainAndShare(self, dic): '''主套餐共享受理''' logger.info("开始参数化......") index = int(dic.get('NO')) logger.info('开始执行第{}个用例,接口入参:{}'.format(index, dic)) accessNum = str(dic.get('ACCESS_NUM')) logger.info("主卡:" + accessNum) VICE_ACCESS_NUM = dic.get('VICE_ACCESS_NUM') logger.info("副卡:" + VICE_ACCESS_NUM) body = { "OFFERS": json.dumps([{ "ENABLE_MODE": "4", "OFFER_ID": "99091283", "OFFER_LIST": [{ "OFFER_ID": "199999999", "ACTION": "0", "ROLE_ID": "999999999" }, { "OFFER_ID": "100000000", "ACTION": "0", "ROLE_ID": "999999999" }, { "OFFER_ID": "100000023", "ACTION": "0", "ROLE_ID": "999999999" }], "ACTION": "0", "OFFER_TYPE": "00" }, { "OFFER_ID": "100000001", "ACTION": "0" }, { "OFFER_ID": "100000200", "ACTION": "0" }]), "SELECTED_OFFER_VALUE": json.dumps([{ "OFFER_ID": "99091283", "ACTION": "0", "ENABLE_MODE": "4", "OFFER_TYPE": "00", "OFFER_LIST": [{ "OFFER_ID": "199999999", "ROLE_ID": "999999999", "ACTION": "0" }, { "OFFER_ID": "100000000", "ROLE_ID": "999999999", "ACTION": "0" }, { "OFFER_ID": "100000023", "ROLE_ID": "999999999", "ACTION": "0" }] }, { "OFFER_ID": "100000001", "ACTION": "0" }, { "OFFER_ID": "100000200", "ACTION": "0" }]), "ACCESS_NUM": accessNum, "SELECTED_OFFER_NAME": "4G飞享138元全国套餐", "MENU_ID": "crm4G12", "LOGIN_TYPE_CODE": "|P", "SELECTED_ACTIVE_NAME": "", "SUBMIT_TYPE": "0", # "page": "oc.person.cs.ChangeMainAndShare", "VICE_ACCESS_NUM": VICE_ACCESS_NUM, # "IDENTITYAUTH_LOG_ID": "", # "service": "ajax", # "listener": "onTradeSubmit", "BILLING_CODES": "99091283", "CHANGE_MAIN_AND_SHARE": "TRUE" } params = { "svcName": "OrderCentre.person.IChangeMainAndShareSV.changeMainAndShare" } params.update(body) print('请求参数:{}'.format(params)) logger.info("开始构建请求......" + "\n") intf_url = rc.get_interface_url("url_interface") logger.info("接口测试地址:" + intf_url) intf_res = self.session.post(url=intf_url, headers=h, data=params) logger.info("接口完整返回信息:" + intf_res.content.decode(encoding='utf-8')) logger.info("处理接口返回数据....") d_intf_res = json.loads(intf_res.content.decode(encoding='utf-8')) x_resultcode = dict_get(d_intf_res, 'X_RESULTCODE', None) if x_resultcode == '0': flowid = dict_get(d_intf_res, 'flowId', None) logger.info("接口处理成功,受理号码为:{},订单交互流水号:{}".format(accessNum, flowid)) print("接口处理成功,受理号码为:{},订单交互流水号:{}".format(accessNum, flowid)) logger.info("开始写入结果xls数据......") write_xlsBycolName_append(file=self.file, row=index, colName='FLOWID', value=flowid) logger.info("测试结果写入xls成功......") else: x_resultinfo = dict_get(d_intf_res, 'x_resultinfo', None) logger.info("接口处理失败,错误信息:{}".format(x_resultinfo)) print("接口处理错误信息:" + x_resultinfo) logger.info("开始写入xls数据......") write_xlsBycolName_append(file=self.file, row=index, colName='RESULT_INFO', value=x_resultinfo) logger.info("测试结果写入xls成功......")