def test_I_updateStudentScore(self): '''成教学员入学考试成绩录入''' extFile = YamlParser('LearnInfo') learnId = extFile.getYamlParms(('CStudent', 'learnId')) web_token = extFile.getYamlParms(('CStudent', '_web_token')) courses = extFile.getYamlParms(('CStudent', 'courses')) param = getJsonParm(courses) courseId0 = param[0]['subjectId'] courseName0 = param[0]['subjectName'] courseId1 = param[1]['subjectId'] courseName1 = param[1]['subjectName'] courseId2 = param[2]['subjectId'] courseName2 = param[2]['subjectName'] case = TestCaseAssembly().setAipParam( 'updateStudentScore', (learnId, web_token, courseId0, courseName0, courseId1, courseName1, courseId2, courseName2), (('data', 'learnId'), ('data', '_web_token'), ('data', 'scores[0].courseId'), ('data', 'scores[0].courseName'), ('data', 'scores[1].courseId'), ('data', 'scores[1].courseName'), ('data', 'scores[2].courseId'), ('data', 'scores[2].courseName'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True)
def setAipData(self, AipFile, keys: dict): '''获取接口请求参数''' '''从模板,配置文件或提取参数中组合''' data0 = YamlParser(AipFile) for k in keys.keys(): data0.setYaml(k, keys[k]) return YamlParser(AipFile).Yaml['data']
def test_0_sUnvs(self): '''随机获取成教院校ID''' intFile = YamlParser('StudentInfo') case = TestCaseAssembly().setAipParam('sUnvs', (intFile.getYamlParms(('CJ', 'recruitType')),), ('data', 'ext1')) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数''' AfterParamCom().saveParam(response.text, 'sUnvs', ('CStudent', 'unvsId'))
def test_8_reviewFee(self): '''成教学员辅导费缴费审核''' extFile = YamlParser('LearnInfo') learnId = extFile.getYamlParms(('CStudent', 'learnId')) subOrderNo = extFile.getYamlParms(('CStudent', 'subOrderNo')) case = TestCaseAssembly().setAipParam('reviewFee', (learnId,subOrderNo), (('data', 'learnId'),('data', 'subOrderNo'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True)
def test_6_toPay(self): '''获取支付订单及web_token''' extFile = YamlParser('LearnInfo') learnId = extFile.getYamlParms(('CStudent', 'learnId')) case = TestCaseAssembly().setAipParam('toPay', (learnId,), (('data', 'learnId'),)) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''提取参数learnId''' AfterParamCom().moreParam(response.text, 'toPay', (('CStudent', 'order'), ('CStudent', '_web_token'))) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True)
def test_2_getOpenTestAreaByCity(self): '''随机获取考区''' extFile = YamlParser('LearnInfo') pfsnId = extFile.getYamlParms(('CStudent', 'pfsnId')) values = (pfsnId,) keys = (('data', 'sId'),) case = TestCaseAssembly().setAipParam('sTaNotStop', values, keys) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数''' AfterParamCom().saveParam(response.text, 'sTaNotStop', ('CStudent', 'taId'))
def test_E_testConfirm_okConfirm(self): '''成教学员考前确认''' extFile = YamlParser('LearnInfo') learnId = extFile.getYamlParms(('CStudent', 'learnId')) case = TestCaseAssembly().setAipParam('okConfirm', (learnId, ), (('data', 'learnId'), )) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True)
def test_7_cj_fd_pay(self): '''成教学员支付辅导费(不使用抵扣)''' extFile = YamlParser('LearnInfo') intFile = YamlParser('StudentInfo') '''提取到的''' order = extFile.getYamlParms(('CStudent', 'order')) learnId = extFile.getYamlParms(('CStudent', 'learnId')) web_token = extFile.getYamlParms(('CStudent', '_web_token')) tutorPayInfos = getJsonParm(order, 'tutorPayInfos')[0] payAmount = payableCount = amount = tutorPayInfos['payable'] itemName = tutorPayInfos['itemName'] orderNo = tutorPayInfos['subOrderNo'] paymentType = 1 '''配置的''' grade = intFile.getYamlParms(('CJ', 'grade')) values = (str(learnId), str(learnId), str(web_token), str(grade), str(grade), str(payableCount), str(payAmount), str(amount), str(itemName), str(orderNo), str(paymentType)) keys = (('data', 'learnId'), ('data', 'payData', 'learnId'), ('data', '_web_token'), ('data', 'grade'), ('data', 'payData', 'grade'), ('data', 'payableCount'), ('data', 'payData', 'payAmount'), ('data', 'payData', 'items', 0, 'amount'), ('data', 'payData', 'items', 0, 'itemName'), ('data', 'payData', 'items', 0, 'orderNo'), ('data', 'paymentType')) case = TestCaseAssembly().setAipParam('pay', values, keys) case[3]['payData']=str(case[3]['payData']) response = YzApi().lapi(method=case[0], headers=DataSource().getHearder("PHearder"), urls=case[2], data=case[3]) self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数:subOrderNo''' DataSource().setLearnInfo('CStudent','subOrderNo',orderNo)
def test_5_stdFeeList(self): '''财务管理搜索结果获取learn_id''' extFile = YamlParser('LearnInfo') mobile = extFile.getYamlParms(('CStudent', 'mobile')) values = (mobile,) keys = (('data', 'mobile'),) case = TestCaseAssembly().setAipParam('stdFeeList', values, keys) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''提取参数learnId''' resJosn = getJsonParm(response.text, 'body') learnId = str(resJosn['data'][0]['learnId']) BeforeParamCom().setLearn((('CStudent', 'learnId'),), learnId) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True)
def test_f_studentModify_passStudentAuditModify(self): '''成教学员新生信息修改提交申请随''' extFile = YamlParser('LearnInfo') modifyId = extFile.getYamlParms(('CStudent', 'modifyId')) case = TestCaseAssembly().setAipParam('passStudentAuditModify', (modifyId, ), (('data', 'modifyId'), )) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True)
def test_0_getGkOpenEnrollCityInfo(self): '''随机获取国开报读城市''' intFile = YamlParser('StudentInfo') case = TestCaseAssembly().setAipParam( 'getGkOpenEnrollCityInfo', (intFile.getYamlParms( ('GK', 'grade'), ), intFile.getYamlParms( ('GK', 'level'))), (('data', 'ext2'), ('data', 'ext1'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数''' AfterParamCom().saveParam(response.text, 'getGkOpenEnrollCityInfo', ('GStudent', 'city'))
def test_A_updateAnnex(self): '''成教学员上传附件''' extFile = YamlParser('LearnInfo') learnId = extFile.getYamlParms(('CStudent', 'learnId')) annexId1 = extFile.getYamlParms(('CStudent', 'annexId1')) annexId2 = extFile.getYamlParms(('CStudent', 'annexId2')) annexId3 = extFile.getYamlParms(('CStudent', 'annexId3')) annexId4 = extFile.getYamlParms(('CStudent', 'annexId4')) annexId = [annexId1, annexId2, annexId3, annexId4] annexType = [1, 2, 3, 4] annexName = ['身份证正面照', '身份证背面照', '学历证书', '相片'] assert0 = True for i in annexId: case = TestCaseAssembly().setAipParam( 'updateAnnex', (i, learnId, annexType[annexId.index(i)], annexName[annexId.index(i)]), (('data', 'annexId'), ('data', 'learnId'), ('data', 'annexType'), ('data', 'annexName'))) data0 = { 'annexFile': ('1.jpg', open( 'C:\\YZeducation\\PyProject\\LYZTest\\test_data\\image\\1.jpg', 'rb'), 'image/jpeg'), 'annexId': str(i), 'annexName': annexName[annexId.index(i)], 'annexType': str(annexType[annexId.index(i)]), 'annexUrl': '', 'isRequire': '1', 'learnId': str(learnId) } data = MultipartEncoder(fields=data0) DataSource().setHearder(data.content_type) response = YzApi().lapi( method=case[0], headers=DataSource().getHearder("regiester"), urls=case[2], data=data) assert1 = MyAssert().assertchar(response.text, ['true', '00']) assert0 = assert0 and assert1
def test_e_studentModify_findStudentAuditModify(self): '''成教学员新生信息修改申请随机获取新考区id''' extFile = YamlParser('LearnInfo') mobile = extFile.getYamlParms(('CStudent', 'mobile')) case = TestCaseAssembly().setAipParam('findStudentAuditModify', (mobile, ), (('data', 'mobile'), )) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数modifyId''' AfterParamCom().saveParam(response.text, 'findStudentAuditModify', ('CStudent', 'modifyId'))
def test_B_getCommonAnnexList(self): '''成教学员获取附件审核crId''' extFile = YamlParser('LearnInfo') learnId = extFile.getYamlParms(('CStudent', 'idCard')) case = TestCaseAssembly().setAipParam('getCommonAnnexList', (learnId, ), (('data', 'idCard'), )) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数crId''' AfterParamCom().saveParam(response.text, 'getCommonAnnexList', ('CStudent', 'crId'))
def test_b_studentChange_findStudentGrade(self): '''成教学员随机获取可转报年级''' intFile = YamlParser('StudentInfo') grade = intFile.getYamlParms(('CJ', 'grade')) case = TestCaseAssembly().setAipParam('findStudentGrade', (grade, ), (('data', 'grade'), )) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数grade列表''' gradeList = getJsonParm(response.text, 'body') BeforeParamCom().setLearn((('CStudent', 'gradeList'), ), str(gradeList))
def test_9_studentModify_findStudentEnrollInfo(self): '''成教学员获取新生信息修改基础数据''' extFile = YamlParser('LearnInfo') learnId = extFile.getYamlParms(('CStudent', 'learnId')) case = TestCaseAssembly().setAipParam('findStudentEnrollInfo', (learnId, ), (('data', 'learnId'), )) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数''' TxJosn = getJsonParm(response.text, 'body') BeforeParamCom().setLearn((('CStudent', 'TxJosn'), ), TxJosn)
def test_a_baseinfo_sUnvs(self): '''成教学员新生信息修改申请随机获取新院校id''' intFile = YamlParser('StudentInfo') recruitType = intFile.getYamlParms(('CJ', 'recruitType')) case = TestCaseAssembly().setAipParam('baseinfo_sUnvs', (recruitType, ), (('data', 'ext1'), )) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数院校idsId''' AfterParamCom().saveParam(response.text, 'baseinfo_sUnvs', ('CStudent', 'sId'))
def test_a_studentChange_edit(self): '''成教学员获取转报web_token''' extFile = YamlParser('LearnInfo') learnId = extFile.getYamlParms(('CStudent', 'learnId')) mobile = extFile.getYamlParms(('CStudent', 'learnId')) case = TestCaseAssembly().setAipParam('studentChange_edit', (learnId, mobile), (('data', 'learnId'), ('data', 'mobile'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数''' AfterParamCom().saveParam(response.text, 'studentChange_edit', ('CStudent', '_web_token'))
def extRegxParam(self,response,YamlFile): '''接口返回数据正则提取''' '''支持多个正则表达式''' re =YamlParser(YamlFile).getYamlParms(('regx',)) TX = [] if isinstance(re,list): for i in re: TX.append(regx(response, i)[0]) return TX else: return regx(response, re)
def test_F_studentScore_edit(self): '''成教学员获取入学考试成绩录入web_token''' extFile = YamlParser('LearnInfo') learnId = extFile.getYamlParms(('CStudent', 'learnId')) idCard = extFile.getYamlParms(('CStudent', 'idCard')) case = TestCaseAssembly().setAipParam('studentScore_edit', (learnId, idCard), (('data', 'learnId'), ('data', 'idCard'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['_web_token']), True) '''提取参数courses+web_token''' AfterParamCom().moreParam(response.text, 'studentScore_edit', (('CStudent', '_web_token'), ('CStudent', 'courses')))
def test_D_annexCheckCharge(self): '''成教学员附件审核-附件审核''' extFile = YamlParser('LearnInfo') annexId1 = extFile.getYamlParms(('CStudent', 'annexId1')) annexId2 = extFile.getYamlParms(('CStudent', 'annexId2')) annexId3 = extFile.getYamlParms(('CStudent', 'annexId3')) annexId4 = extFile.getYamlParms(('CStudent', 'annexId4')) learnId = extFile.getYamlParms(('CStudent', 'learnId')) annexId = [annexId1, annexId2, annexId3, annexId4] assert0 = True for i in annexId: case = TestCaseAssembly().setAipParam('annexCheckCharge', (i, learnId), (('data', 'annexId'), ('data', 'learnId'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) assert1 = MyAssert().assertchar(response.text, ['true', '00']) assert0 = assert0 and assert1
def test_9_getAnnexList(self): '''成教学员获取附件ID''' extFile = YamlParser('LearnInfo') intFile = YamlParser('StudentInfo') learnId = extFile.getYamlParms(('CStudent', 'learnId')) recruitType = intFile.getYamlParms(('CJ', 'recruitType')) case = TestCaseAssembly().setAipParam('getAnnexList', (learnId, recruitType), (('data', 'learnId'), ('data', 'recruitType'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数annexId''' resJosn = getJsonParm(response.text, 'body') annexId1 = resJosn['data'][0]['annexId'] annexId2 = resJosn['data'][1]['annexId'] annexId3 = resJosn['data'][2]['annexId'] annexId4 = resJosn['data'][3]['annexId'] BeforeParamCom().setLearn((('CStudent', 'annexId1'), ), annexId1) BeforeParamCom().setLearn((('CStudent', 'annexId2'), ), annexId2) BeforeParamCom().setLearn((('CStudent', 'annexId3'), ), annexId3) BeforeParamCom().setLearn((('CStudent', 'annexId4'), ), annexId4)
def test_3_showFeeList(self): '''获取收费标准''' extFile = YamlParser('LearnInfo') intFile = YamlParser('StudentInfo') pfsnId = extFile.getYamlParms(('CStudent', 'pfsnId')) taId = extFile.getYamlParms(('CStudent', 'taId')) recruitType = intFile.getYamlParms(('CJ', 'recruitType')) scholarship = intFile.getYamlParms(('CJ', 'scholarships')) values = (pfsnId, taId, recruitType, scholarship) keys = (('data', 'pfsnId'), ('data', 'taId'), ('data', 'recruitType'), ('data', 'scholarship')) case = TestCaseAssembly().setAipParam('showFeeList', values, keys) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数''' AfterParamCom().saveParam(response.text, 'showFeeList', ('CStudent', 'feeList'))
def test_C_annexCheck(self): '''成教学员附件审核-总审''' extFile = YamlParser('LearnInfo') intFile = YamlParser('StudentInfo') recruitType = intFile.getYamlParms(('CJ', 'recruitType')) crId = extFile.getYamlParms(('CStudent', 'crId')) learnId = extFile.getYamlParms(('CStudent', 'learnId')) case = TestCaseAssembly().setAipParam( 'annexCheck', (crId, recruitType, learnId), (('data', 'crId'), ('data', 'recruitType'), ('data', 'learnId'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True)
def test_J_stdEnroll_enroll(self): '''成教学员录取''' extFile = YamlParser('LearnInfo') intFile = YamlParser('StudentInfo') level = intFile.getYamlParms(('CJ', 'level')) learnId = extFile.getYamlParms(('CStudent', 'learnId')) grade = intFile.getYamlParms(('CJ', 'grade')) pfsnId = extFile.getYamlParms(('CStudent', 'pfsnId')) unvsId = extFile.getYamlParms(('CStudent', 'unvsId')) case = TestCaseAssembly().setAipParam( 'stdEnroll', (learnId, level, grade, pfsnId, unvsId), (('data', 'learnId'), ('data', 'level'), ('data', 'grade'), ('data', 'pfsnId'), ('data', 'unvsId'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True)
def test_1_sPfsnByOnScholarship(self): '''随机获取成教专业''' intFile = YamlParser('StudentInfo') extFile = YamlParser('LearnInfo') grade = intFile.getYamlParms(('CJ', 'grade')) level = intFile.getYamlParms(('CJ', 'level')) sId = extFile.getYamlParms(('CStudent', 'unvsId')) values = (grade, level, sId) keys = (('data', 'ext2'), ('data', 'ext1'), ('data', 'sId')) case = TestCaseAssembly().setAipParam('sPfsnByOnScholarship', values, keys) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True,) '''提取参数''' AfterParamCom().saveParam(response.text, 'sPfsnByOnScholarship', ('CStudent', 'pfsnId'))
def test_4_showFeeList(self): '''获取国开报读收费标准信息''' intFile = YamlParser('StudentInfo') extFile = YamlParser('LearnInfo') case = TestCaseAssembly().setAipParam( 'showFeeList', (intFile.getYamlParms(('GK', 'recruitType')), intFile.getYamlParms(('GK', 'scholarships')), extFile.getYamlParms(('GStudent', 'pfsnId')), extFile.getYamlParms(('GStudent', 'taId'))), (('data', 'recruitType'), ('data', 'scholarship'), ('data', 'pfsnId'), ('data', 'taId'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数''' AfterParamCom().saveJson(response.text, (('body', 'feeInfo', 'feeId'), ), (('GStudent', 'feeId'), )) AfterParamCom().saveParam(response.text, 'showFeeList', ('GStudent', 'feeList'))
def test_b_sPfsnByTransaction(self): '''成教学员新生信息修改申请随机获取专新业id''' intFile = YamlParser('StudentInfo') extFile = YamlParser('LearnInfo') ext1 = intFile.getYamlParms(('CJ', 'level')) BeforeParamCom().setLearn((('CStudent', 'npfsnLevel'), ), ext1) ext2 = intFile.getYamlParms(('CJ', 'grade')) ext3 = intFile.getYamlParms(('CJ', 'scholarships')) sId = extFile.getYamlParms(('CStudent', 'sId')) case = TestCaseAssembly().setAipParam( 'sPfsnByTransaction', (ext1, ext2, ext3, sId), (('data', 'ext1'), ('data', 'ext2'), ('data', 'ext3'), ('data', 'sId'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数pfsnId''' AfterParamCom().saveParam(response.text, 'sPfsnByTransaction', ('CStudent', 'newPfsnId'))
def test_3_getOpenPfsnByTaId(self): '''随机获取国开报读专业pfsnId+专业名称pfsnName+专业编号pfsnCode''' intFile = YamlParser('StudentInfo') extFile = YamlParser('LearnInfo') case = TestCaseAssembly().setAipParam( 'getOpenPfsnByTaId', (intFile.getYamlParms( ('GK', 'level')), intFile.getYamlParms( ('GK', 'grade')), extFile.getYamlParms( ('GStudent', 'taId'))), (('data', 'ext2'), ('data', 'ext3'), ('data', 'ext1'))) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True) '''提取参数''' AfterParamCom().saveParam(response.text, 'getOpenPfsnByTaId', (('GStudent', 'pfsnId'), ('GStudent', 'pfsnName'), ('GStudent', 'pfsnCode')))
def test_d_studentModify_insertStudentModify(self): '''成教学员新生信息修改发起申请''' extFile = YamlParser('LearnInfo') npfsnLevel = extFile.getYamlParms(('CStudent', 'npfsnLevel')) newPfsnId = extFile.getYamlParms(('CStudent', 'newPfsnId')) newTaId = extFile.getYamlParms(('CStudent', 'newTaId')) newUnvsId = extFile.getYamlParms(('CStudent', 'sId')) TxJosn = extFile.getYamlParms(('CStudent', 'TxJosn')) case = TestCaseAssembly().setAipParam( 'insertStudentModify', (npfsnLevel, newPfsnId, newTaId, newUnvsId), (('data', 'npfsnLevel'), ('data', 'newPfsnId'), ('data', 'newTaId'), ('data', 'newTaId'))) case[3].update(TxJosn) response = YzApi().lapi(method=case[0], headers=case[1], urls=case[2], data=case[3]) '''断言''' self.assertTrue(MyAssert().assertchar(response.text, ['true', '00']), True)