def test_00_login(self): t = DataSource().getAllyaml('Logining') url = str(t.get('urls')) data = dict(t.get('data')) try: data['mobile'] = self.locust.queueData.get() print(data) except queue.Empty: print('no data exit') exit(0) headers = { "Content-Type": 'application/x-www-form-urlencoded; charset=UTF-8', "Host": 'bms-3.yzwill.cn', "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, likeGecko) Chrome/73.0.3683.86 Safari/537.36" } response = self.client.post(url=url, data=data, headers=headers, verify=False) print(response.text) if response.status_code == 200: print("success") else: print("fails")
def test_5_gk_normal_register(self, city, unvsId, feeId, feeList, pfsnId, pfsnName, pfsnCode, taId, taName): '''随机录入国开类型学员学员''' intFile = YamlParser('StudentInfo') '''从配置文件获取参数''' grade = intFile.getYamlParms(('GK', 'grade')) recruitType = intFile.getYamlParms(('GK', 'recruitType')) scholarship = intFile.getYamlParms(('GK', 'scholarships')) '''从参数文件获取参数''' mobile = DataSource().getMobile() idCard = DataSource().getIdcard() pfsnLevel = intFile.getYamlParms(('GK', 'pfsnLevel')) '''将参数组合到接口文件''' values = (str(grade), str(recruitType), str(scholarship), str(city), str(unvsId), str(feeList), str(pfsnCode), str(pfsnId), str(pfsnName), str(taId), str(taName), mobile, idCard, str(pfsnLevel), str(feeId)) keys = (('data', 'grade'), ('data', 'recruitType'), ('data', 'scholarship'), ('data', 'city'), ('data', 'unvsId'), ('data', 'feeList'), ('data', 'pfsnCode'), ('data', 'pfsnId'), ('data', 'pfsnName'), ('data', 'taId'), ('data', 'taName'), ('data', 'mobile'), ('data', 'idCard'), ('data', 'pfsnLevel'), ('data', 'feeId')) case = TestCaseAssembly().setAipParam('GrecruitAdd', values, keys) data = MultipartEncoder(fields=case[3]) headers = {'Accept': 'application/json, text/javascript, */*; q=0.01', 'Content-Type': '', 'Host': 'bms.yzwill.cn', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'} headers["Content-Type"] = data.content_type response = self.client.post(url=case[2], data=data, headers=headers) if response.status_code == 200: print("success") else: print("fails")
def test_5_gk_normal_register(self): '''随机录入国开类型学员学员''' intFile = YamlParser('StudentInfo') extFile = YamlParser('LearnInfo') '''从配置文件获取参数''' grade = intFile.getYamlParms(('GK', 'grade')) recruitType = intFile.getYamlParms(('GK', 'recruitType')) scholarship = intFile.getYamlParms(('GK', 'scholarships')) '''从参数文件获取参数''' city = extFile.getYamlParms(('GStudent', 'city')) unvsId = extFile.getYamlParms(('GStudent', 'unvsId')) feeId = extFile.getYamlParms(('GStudent', 'feeId')) feeList = extFile.getYamlParms(('GStudent', 'feeList')) pfsnCode = extFile.getYamlParms(('GStudent', 'pfsnCode')) pfsnId = extFile.getYamlParms(('GStudent', 'pfsnId')) pfsnName = extFile.getYamlParms(('GStudent', 'pfsnName')) taId = extFile.getYamlParms(('GStudent', 'taId')) taName = extFile.getYamlParms(('GStudent', 'taName')) mobile = BeforeParamCom().getPhone() idCard = BeforeParamCom().getCard() self.log.info('学员手机号:' + mobile) self.log.info('学员身份证号:' + str(idCard)) BeforeParamCom().setLearn((('GStudent', 'mobile'), ), mobile) BeforeParamCom().setLearn((('GStudent', 'idCard'), ), idCard) pfsnLevel = intFile.getYamlParms(('GK', 'pfsnLevel')) '''将参数组合到接口文件''' values = (str(grade), str(recruitType), str(scholarship), str(city), str(unvsId), str(feeList), str(pfsnCode), str(pfsnId), str(pfsnName), str(taId), str(taName), mobile, idCard, str(pfsnLevel), str(feeId)) keys = (('data', 'grade'), ('data', 'recruitType'), ('data', 'scholarship'), ('data', 'city'), ('data', 'unvsId'), ('data', 'feeList'), ('data', 'pfsnCode'), ('data', 'pfsnId'), ('data', 'pfsnName'), ('data', 'taId'), ('data', 'taName'), ('data', 'mobile'), ('data', 'idCard'), ('data', 'pfsnLevel'), ('data', 'feeId')) case = TestCaseAssembly().setAipParam('GrecruitAdd', values, keys, 'regiester') data = MultipartEncoder(fields=case[3]) DataSource().setHearder(data.content_type) response = YzApi().lapi(method=case[0], headers=DataSource().getHearder("regiester"), urls=case[2], data=data)
def test_5_gk_normal_register(self): '''随机录入国开类型学员学员''' city = self.test_0_getGkOpenEnrollCityInfo() unvsId = self.test_1_sUnvs() ta = self.test_2_getOpenTestAreaByCity(city) pfsn = self.test_3_getOpenPfsnByTaId(ta[0]) pfsnId = pfsn[0] pfsnCode = pfsn[1] free = self.test_4_showFeeList(pfsn[0], ta[0]) feeId = free[0] feeList = free[1] taId = ta[0] taName = ta[1] pfsnName = pfsn[2] intFile = YamlParser('StudentInfo') '''从配置文件获取参数''' grade = intFile.getYamlParms(('GK', 'grade')) recruitType = intFile.getYamlParms(('GK', 'recruitType')) scholarship = intFile.getYamlParms(('GK', 'scholarships')) '''从参数文件获取参数''' mobile = DataSource().getMobile() idCard = DataSource().getIdcard() pfsnLevel = intFile.getYamlParms(('GK', 'pfsnLevel')) '''将参数组合到接口文件''' values = (str(grade), str(recruitType), str(scholarship), str(city), str(unvsId), str(feeList), str(pfsnCode), str(pfsnId), str(pfsnName), str(taId), str(taName), mobile, idCard, str(pfsnLevel), str(feeId)) keys = (('data', 'grade'), ('data', 'recruitType'), ('data', 'scholarship'), ('data', 'city'), ('data', 'unvsId'), ('data', 'feeList'), ('data', 'pfsnCode'), ('data', 'pfsnId'), ('data', 'pfsnName'), ('data', 'taId'), ('data', 'taName'), ('data', 'mobile'), ('data', 'idCard'), ('data', 'pfsnLevel'), ('data', 'feeId')) case = TestCaseAssembly().setAipParam('GrecruitAdd', values, keys) data = MultipartEncoder(fields=case[3]) headers = {'Content-Type': ''} headers["Content-Type"] = data.content_type response = self.session.post(url=case[2], data=data, headers=headers) if response.status_code == 200: print("gkregister success") else: print("gkregister fails")
def test_00_login(self): t = DataSource().getAllyaml('Logining') url = str(t.get('urls')) data = dict(t.get('data')) headers = { "Content-Type": 'application/x-www-form-urlencoded; charset=UTF-8', "Host": 'bms-3.yzwill.cn', "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, likeGecko) Chrome/73.0.3683.86 Safari/537.36" } req = self.client.post(url=url, data=data, headers=headers, verify=False) if req.status_code == 200: print("success") else: print("fails")