def test_cp_zdqueryAllpage(self, gettokenfixture): s = gettokenfixture self.log.info("采购申请明细分配查询") r = SRMBase(s) msg = r.cp_zdqueryAllpage() self.log.info("获取结果是:%s" % msg.json()) assert "allotQty" in msg.text
def test_cpdetail_userpage(self, gettokenfixture, value, expect): s = gettokenfixture self.log.info("---转交采购员查询接口---") r = SRMBase(s) msg = r.cpdetail_userpage(value) self.log.info("获取请求结果:%s" % msg.json()) assert msg.json()["msg"] == expect["msg"]
def test_baseStorageLocation(self, gettokenfixture): s = gettokenfixture self.log.info("根据工厂查询库位") r = SRMBase(s) msg = r.baseStorageLocation() self.log.info("查询第一条结果是:%s" % msg.json()["data"][0]) assert msg.json()["msg"] == "查询成功"
def test_basePlant(self, gettokenfixture): s = gettokenfixture self.log.info("根据公司查询工厂") r = SRMBase(s) msg = r.basePlant() self.log.info("查询第一条结果是:%s" % msg.json()["data"][0]) assert msg.json()["msg"] == "查询成功"
def test_cpselect_log(self, gettokenfixture): s = gettokenfixture self.log.info("---采购申请查看-获取日志接口---") r = SRMBase(s) msg = r.cpselect_log() self.log.info("获取结果是:%s" % msg.json()) a_msg = jsonpath.jsonpath(msg.json(), '$..busId')[0] assert a_msg == "8e926428-c823-418d-9264-28c823a18d03"
def test_cp_zdstatusPage(self, gettokenfixture, key, status, expect): s = gettokenfixture self.log.info("采购申请转单状态查询") r = SRMBase(s) msg = r.cp_zdstatusPage(key, status) self.log.info("获取的结果是:%s" % msg.json()) a_msg = jsonpath.jsonpath(msg.json(), '$..requestDetailStatus')[0] assert a_msg == expect
def test_SysUser_state(self, gettokenfixture, state, expect): s = gettokenfixture url = os.environ["host"] + "/srm/api/v1/sysUser/state" data = {"account": 70061501, "state": state} msg = s.put(url, data=data) sta = SRMBase(s).sysUser_page("vendorAccount", "70061501") sta.msg = jsonpath.jsonpath(sta.json(), '$..state')[0] assert sta.msg == expect
def test_cp_examineRecordsPage(self, gettokenfixture, status, expect): s = gettokenfixture self.log.info("配额超标审核记录状态查询") r = SRMBase(s) msg = r.cp_examineRecordsPage(status) self.log.info("获取的结果是:%s" % msg.json()) a_msg = jsonpath.jsonpath(msg.json(), '$..status')[0] assert a_msg == expect
def test_cpLackMaterialSub_statusPage(self, gettokenfixture, key, value): s = gettokenfixture self.log.info("缺料提报状态查询接口") r = SRMBase(s) msg = r.cpLackMaterialSub_statusPage(key, value) status = jsonpath.jsonpath(msg.json(), '$..status')[0] self.log.info("查询结果是:%s" % msg.json()) assert status == value
def test_customByPlantPage(self, gettokenfixture): s = gettokenfixture self.log.info("根据工厂获取物料") r = SRMBase(s) msg = r.customByPlantPage() self.log.info("查询到第一页条数是:%s" % msg.json()["data"]["total"]) assert msg.json()["success"] == 1 assert msg.json()["data"]["total"] == 6
def test_cpselect_main(self, gettokenfixture): s = gettokenfixture self.log.info('---采购申请查看-获取主单接口---') r = SRMBase(s) msg = r.cpselect_main() self.log.info('获取结果是:%s' % msg.json()) assert msg.json( )["data"]["tempId"] == "8e926428-c823-418d-9264-28c823a18d03"
def test_sysUser_page(self, gettokenfixture, key, value, expect): #用户管理查询接口测试 s = gettokenfixture self.log.info('-----用户查询接口-----') r = SRMBase(s) msg = r.sysUser_page(key, value) self.log.info('获取请求结果:%s' % msg.json()) result = jsonpath.jsonpath(msg.json(), '$..phone')[0] assert result == expect
def test_cpdetail_transfer(self, gettokenfixture, account): s = gettokenfixture self.log.info("---采购申请明细转交接口---") r = SRMBase(s) r.cpdetail_transfer(account) msg = r.cpdetail_page("purchaseRequestNo", "PR2021042000011") self.log.info("转交后查询结果:%s" % msg.json()) ass = jsonpath.jsonpath(msg.json(), '$..buyerAccount')[0] assert ass == account
def test_cpLackMaterialSub_add(self, gettokenfixture, processamento): s = gettokenfixture self.log.info("缺料提报新增") r = SRMBase(s) msg = r.cpLackMaterialSub_add(processamento) ass = r.cpLackMaterialSub_qlpage("productName", msg[1]) ass_processamento = jsonpath.jsonpath(ass.json(), '$..processamento')[0] assert ass_processamento == processamento
def test_login(self, username, pwd, expect): # 登录接口测试 s = requests.session() # 定义session会话 self.log.info('------用户登录接口-----') shili = SRMBase(s) # 实例化 msg = shili.login(username, pwd) self.log.info('获取请求结果:%s' % msg.json()) # print(msg.json()) if msg.status_code == 200: assert msg.json()["license"] == expect['license'] else: assert msg.json()["msg"] == expect['msg']
def test_cpLackMaterialSub_EditSave(self, gettokenfixture, processamento): s = gettokenfixture self.log.info("缺料提报编辑保存") r = SRMBase(s) msg = r.cpLackMaterialSub_EditSave(processamento) page = r.cpLackMaterialSub_qlpage("productName", "3e316193-33d7-4dbe-b161") ass_processamento = jsonpath.jsonpath(page.json(), '$..processamento')[0] assert msg.json()["success"] == 1 assert ass_processamento == processamento
def test_sysuser(self, sysUser_sql, gettokenfixture, username, phone, expect): # 用户新增接口测试 s = gettokenfixture self.log.info('-----用户新增接口-----') shili = SRMBase(s) msg = shili.sysuser(username, phone) ass = shili.sysUser_page("userName", username) print("查询结果是{}".format(ass.text)) ass_phone = jsonpath.jsonpath(ass.json(), '$..phone')[0] self.log.info('获取请求结果:%s' % msg.json()) assert msg.json()["success"] == expect["success"] assert ass_phone == phone
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_cp_examineRecordsPg(self, gettokenfixture, key, value): s = gettokenfixture self.log.info("配额超标审核记录查询") r = SRMBase(s) msg = r.cp_examineRecordsPg(key, value) self.log.info("获取的结果是:%s" % msg.json()) a_msg = jsonpath.jsonpath(msg.json(), '$..purchaseRequestNo')[0] b_msg = jsonpath.jsonpath(msg.json(), '$..materialCode')[0] if key == "purchaseRequestNo": assert a_msg == value else: assert b_msg == value
def test_cpdetail_statuspage_data(self, gettokenfixture, detailstatus, status, ds_expect, s_expect): s = gettokenfixture self.log.info("---采购申请明细状态查询---") r = SRMBase(s) msg = r.cpdetail_statuspage(detailstatus, status) ass_ds = jsonpath.jsonpath(msg.json(), '$..requestDetailStatus')[0] ass_s = jsonpath.jsonpath(msg.json(), '$..status')[0] ass1 = repr(ass_ds) ass2 = repr(ass_s) assert ass1 in ds_expect assert ass2 in s_expect
def test_cpLackMaterialSub_page(self, gettokenfixture, key, value, expect): s = gettokenfixture self.log.info("----采购申请查询接口口----") r = SRMBase(s) msg = r.cpLackMaterialSub_page(key, value) self.log.info("获取请求结果: %s" % msg.json()) if key == "purchaseRequestNo": result = jsonpath.jsonpath(msg.json(), '$..purchaseRequestNo')[0] assert result == expect else: result = jsonpath.jsonpath(msg.json(), '$..remark')[0] assert expect in result
def test_buyerConfirm_page(self, gettokenfixture, key, value): s = gettokenfixture self.log.info("采购员确认查询") r = SRMBase(s) msg = r.buyerConfirm_page(key, value) self.log.info("查询结果是:%s" % msg.json()) lackMaterialSubNo = jsonpath.jsonpath(msg.json(), '$..lackMaterialSubNo')[0] materialCode = jsonpath.jsonpath(msg.json(), '$..materialCode')[0] if key == "lackMaterialSubNo": assert lackMaterialSubNo == value else: assert materialCode == value
def test_cp_statuspage(self, gettokenfixture, syncstatus, status, ss_expect, s_expect): s = gettokenfixture self.log.info("采购申请状态查询接口") r = SRMBase(s) msg = r.cp_statuspage(syncstatus, status) self.log.info("获取结果是:%s" % msg.json()) ass_ss = jsonpath.jsonpath(msg.json(), '$..syncStatus')[0] ass_s = jsonpath.jsonpath(msg.json(), '$..status')[0] ass1 = repr(ass_ss) ass2 = repr(ass_s) assert ass1 in ss_expect assert ass2 in s_expect
def test_lackMaterial(self, gettokenfixture, key, value): s = gettokenfixture self.log.info("缺料提报删除") r = SRMBase(s) page = r.cpLackMaterialSub_statusPage(key, value) self.log.info("查询第一条是:%s" % page.json()["data"]["records"][0]) lackMaterialSubId = jsonpath.jsonpath(page.json(), '$..lackMaterialSubId')[0] msg = r.lackMaterial(lackMaterialSubId) sql = "SELECT STATE FROM CP_LACK_MATERIAL_SUB " \ "WHERE LACK_MATERIAL_SUB_ID = '%s'" % lackMaterialSubId state = Db_Oracle().select(sql) assert state["STATE"] == 0
def test_customPage(self, gettokenfixture, key, value): s = gettokenfixture self.log.info("配额超标审核查询") r = SRMBase(s) msg = r.cp_customPage(key, value) self.log.info("查询结果为:%s" % msg.json()) purchaseRequestNo = jsonpath.jsonpath(msg.json(), '$..purchaseRequestNo')[0] materialCode = jsonpath.jsonpath(msg.json(), '$..materialCode')[0] if key == "materialCode": assert materialCode == value else: assert purchaseRequestNo == value
def test_buyerCareOf(self, gettokenfixture, admintokenfixture, sysUser, buyerAccount, expect): s = gettokenfixture admin = admintokenfixture self.log.info("采购员确认页面转交") r = SRMBase(s) a = SRMBase(admin) try: if buyerAccount == "zhongzijian": give = r.buyerCareOf(sysUser, buyerAccount) print("give:", give.text) a_page = a.buyerConfirm_page("lackMaterialSubNo", expect) self.log.info("admin查询到结果是:%s" % a_page.json()) give_lackMaterialSubNo = jsonpath.jsonpath( a_page.json(), '$..lackMaterialSubNo')[0] assert give_lackMaterialSubNo == expect assert give.json()["success"] == 1 else: give_back = a.buyerCareOf(sysUser, buyerAccount) print(give_back.text) s_page = r.buyerConfirm_page("lackMaterialSubNo", expect) self.log.info("zhongzijian查询到结果是:%s" % s_page.json()) give_back_lackMaterialSubNo = jsonpath.jsonpath( s_page.json(), '$..lackMaterialSubNo')[0] assert give_back_lackMaterialSubNo == expect assert give_back.json()["success"] == 1 except: self.log.info("订单或订单顺序异常")
def test_cpLackMaterialSub_save(self, gettokenfixture, caigouyuan, expect): s = gettokenfixture self.log.info("-----采购申请保存接口-----") r = SRMBase(s) msg = r.cpLackMaterialSub_save(caigouyuan) jg = msg[0] self.log.info("获取请求结果:%s" % jg.json()) rem = r.cpLackMaterialSub_page("purchaseRequestNo", "PR2021032000011") print(rem.json()) rem.cgy = jsonpath.jsonpath(rem.json(), '$..buyerAccount')[0] rem.rem = jsonpath.jsonpath(rem.json(), '$..remark')[0] assert jg.json()["success"] == 1 assert rem.cgy == expect assert rem.rem == "{}".format(msg[1])
def test_cpdetail_page(self, gettokenfixture, key, value, expect): s = gettokenfixture self.log.info("----采购申请明细查询接口口----") r = SRMBase(s) msg = r.cpdetail_page(key, value) self.log.info("获取请求结果: %s" % msg.json()) if key == "purchaseRequestNo": result = jsonpath.jsonpath(msg.json(), '$..purchaseRequestNo')[0] assert result == expect elif key == "materialCode": result = jsonpath.jsonpath(msg.json(), '$..materialCode')[0] assert result == expect else: result = jsonpath.jsonpath(msg.json(), '$..buyerAccount')[0] assert result == expect
def test_SysUser_put(self, gettokenfixture, username, phone, role, expect, expect1, expect2): s = gettokenfixture self.log.info('-----用户编辑接口-----') r = SRMBase(s) putmsg = r.SysUser_put(username, phone, role) self.log.info('获取请求结果:{}'.format(putmsg.json())) selmsg = r.sysUser_page("phone", "15555555552") self.log.info('获取请求结果:{}'.format(selmsg.json())) result = jsonpath.jsonpath(selmsg.json(), '$..phone')[0] result1 = jsonpath.jsonpath(selmsg.json(), '$..userName')[0] result2 = jsonpath.jsonpath(selmsg.json(), '$..roleNames')[0] print(result2) assert result == expect assert result1 == expect1 assert result2 == expect2
def test_cpLackMaterialSub_statusPage(self, gettokenfixture, key, value): s = gettokenfixture self.log.info("缺料提报查询接口") r = SRMBase(s) msg = r.cpLackMaterialSub_qlpage(key, value) lackMaterialSubNo = jsonpath.jsonpath(msg.json(), '$..lackMaterialSubNo')[0] materialCode = jsonpath.jsonpath(msg.json(), '$..materialCode')[0] createBy = jsonpath.jsonpath(msg.json(), '$..createBy')[0] self.log.info("查询结果是:%s" % msg.json()) if key == "lackMaterialSubNo": assert lackMaterialSubNo == value elif key == "materialCode": assert materialCode == value else: assert createBy == value