def test_cpPurchaseRequestOverproof(self, gettokenfixture, auditFlag, expect): s = gettokenfixture self.log.info("----采购申请配额超标审核----") r = SRMBase(s) uid = r.srm_uuid() r.cpLackMaterialSub_Temp(uid, code="105000007", demand=401) # 超标采购申请新增 msg = r.cpLackMaterialSub_push(uid, caigouyuan="zhongzijian") result = msg[0] self.log.info("获取新增结果{}".format(result.json())) try: msg_getRequestid = r.cp_zdpage(key="materialCode", value="105000007") # 查询目标采购申请 Requestid = jsonpath.jsonpath(msg_getRequestid.json(), '$..purchaseRequestId')[0] Detailid = jsonpath.jsonpath(msg_getRequestid.json(), '$..requestDetailId')[0] self.log.info("获取采购申请ID:%s" % Requestid) except: self.log.error("获取采购申请数据错误") msg_allotDty = r.cp_zdallotDty(Requestid, Detailid) # 分配采购申请 Alloid = msg_allotDty.json()["data"][0] commit = r.cp_zdcomits(Requestid, Detailid, Alloid) #分配页面提交 sql = "UPDATE BUSINESS_WAIT_APPROVE_RECORD SET APPROVE_BY = 'zhongzijian' WHERE PROCESS_NAME = '采购申请超标审批流'" Db_Oracle().update(sql) page = r.cp_customPage("materialCode", "105000007") auditid = jsonpath.jsonpath(page.json(), '$..requestOverproofId')[0] purchaseRequestNo = jsonpath.jsonpath(page.json(), '$..purchaseRequestNo')[0] msg = r.cp_audit(auditid, auditFlag) self.log.info("审核结果是:%s" % msg.json()) ass = r.cp_examineRecordsPg("purchaseRequestNo", purchaseRequestNo) status = jsonpath.jsonpath(ass.json(), '$..status')[0] assert status == expect
def test_cp_zdpage(self, gettokenfixture, key, value, expect): s = gettokenfixture self.log.info("采购申请转单查询") r = SRMBase(s) msg = r.cp_zdpage(key, value) self.log.info("获取请求结果:%s" % msg.json()) a_msg = jsonpath.jsonpath(msg.json(), '$..requestDetailRemark')[0] b_msg = jsonpath.jsonpath(msg.json(), '$..createBy')[0] if key == "requestDetailRemark": assert a_msg == expect else: assert b_msg == expect
def test_cpzdcancel(self, gettokenfixture): s = gettokenfixture self.log.info("采购申请转单取消分配") r = SRMBase(s) RequestsNo = r.cp_zdstatusPage("requestDetailStatus100", "100") print("请求结果是%s" % RequestsNo.text) No = jsonpath.jsonpath(RequestsNo.json(), '$..purchaseRequestNo')[0] Requestid = jsonpath.jsonpath(RequestsNo.json(), '$..purchaseRequestId')[0] Detailid = jsonpath.jsonpath(RequestsNo.json(), '$..requestDetailId')[0] Dty = r.cp_zdallotDty(Requestid, Detailid) Alloid = Dty.json()["data"][0] msg = r.cp_zdcacle(Alloid, Requestid, Detailid, No) self.log.info("取消结果是:%s" % msg.text) ass_No = r.cp_zdpage("purchaseRequestNo", No) assert ass_No.json()["data"]["total"] == 1
def test_cpzdcommit(self, gettokenfixture, bool, expect): s = gettokenfixture self.log.info("---采购申请转单提交---") r = SRMBase(s) try: msg_getRequestid = r.cp_zdpage("requestDetailRemark", "自动化导入") # 查询目标采购申请 Requestid = jsonpath.jsonpath(msg_getRequestid.json(), '$..purchaseRequestId')[0] Detailid = jsonpath.jsonpath(msg_getRequestid.json(), '$..requestDetailId')[0] self.log.info("获取采购申请ID:%s" % Requestid) except: self.log.error("自动化导入数据已耗尽") msg_allotDty = r.cp_zdallotDty(Requestid, Detailid) # 分配采购申请 Alloid = msg_allotDty.json()["data"][0] self.log.info("分配的ID是:%s" % msg_allotDty.json()["data"][0]) msg_commit = r.cp_zdcommit(Requestid, Detailid, Alloid) # 分配页面的提交 self.log.info("提交的结果是:%s" % msg_commit.json()) msg_traceid = r.cp_queryByCompanyVendor("500973", "6100", "A01") # 获取可提交明细 for jg in msg_traceid.json()['data']: if jg['requestAllotId'] == Alloid: break Tranceid = jg['requestTransferId'] msg_jlcommit = r.cp_zdjlcommit(Tranceid, Detailid, Alloid) # 转单页面的提交 tempid = msg_jlcommit.json()["data"]["tempId"] self.log.info("获取的tempID是:%s" % tempid) msg_page = r.cp_ordertempPage(tempid) # 根据tempid查询获取传参 detailtempid = jsonpath.jsonpath(msg_page.json(), '$..detailTempId')[0] orderdetailid = jsonpath.jsonpath(msg_page.json(), '$..orderDetailId')[0] msg_put = r.cp_orderDetailEdit(tempid, detailtempid, Tranceid, orderdetailid) #更新采购订单明细 try: msg_jccommit = r.cp_cgsqjccommit(tempid, bool) # 最后提交采购订单 self.log.info("生成采购订单号是:%s" % msg_jccommit.json()["msg"]) except: self.log.error("采购订单提交失败") msg = r.cp_orderpage("purchaseOrderNo", msg_jccommit.json()["msg"]) status = jsonpath.jsonpath(msg.json(), '$..status')[0] assert msg.json()["data"]["total"] == 1 assert status == expect