def test_16_v1_bear_teacher_recommend_job(self, getKey): """老师端:推荐/取消推荐优秀作业-推荐<br>https://mobile.yunshuxie.com/v1/bear/teacher/recommend_job.htm.htm<br>{"timeLineId":"","excellence":"1"}""" bearWord_timelineId = getKey["bearWord_timelineId"] if bearWord_timelineId: url = r"https://mobile.yunshuxie.com" + r"/v1/bear/teacher/recommend_job.htm" params = {"timeLineId": bearWord_timelineId, "excellence": "1"} # logging.info(url + lianjiefu + json.dumps(params, ensure_ascii=False) + fengefu) str_params = json.dumps(params, ensure_ascii=False, encoding="utf8") print str_params cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, self.phone) self.session.cookies = cookies self.resp = self.session.post(url=url, data=params) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") #logging.info(url + lianjiefu + self.resp.content + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: print u"当前教师未存在待批改作业" raise Exception, u"当前教师未存在待批改作业"
def test_09_v1_bear_teacher_not_correct_list(self): """老师端:待批改列表<br>https://mobile.yunshuxie.com/v1/bear/teacher/not_correct_list.htm<br>{"page":"","pageSize":""}""" url = r"https://mobile.yunshuxie.com" + r"/v1/bear/teacher/not_correct_list.htm" params = {"page": "1", "pageSize": "10"} # logging.info(url + lianjiefu + json.dumps(params, ensure_ascii=False) + fengefu) str_params = json.dumps(params, ensure_ascii=False, encoding="utf8") print str_params cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, self.phone) self.session.cookies = cookies self.resp = self.session.post(url=url, data=params) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") #logging.info(url + lianjiefu + self.resp.content + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) if result["data"]["notCorrectJobList"]: return [result["data"]["notCorrectJobList"][0]["timelineId"]] else: print u"当前教师未存在待批改作业" raise Exception, u"当前教师未存在待批改作业"
def test_10_v1_bear_teacher_bear_task(self, getKey): """老师端:用户作业详情<br>https://mobile.yunshuxie.com/v1/bear/teacher/bear_task.htm<br>{"timeLineId":""}""" bearWord_timelineId = getKey["bearWord_timelineId"] if bearWord_timelineId: url = r"https://mobile.yunshuxie.com" + r"/v1/bear/teacher/bear_task.htm" params = {"timeLineId": bearWord_timelineId} # logging.info(url + lianjiefu + json.dumps(params, ensure_ascii=False) + fengefu) str_params = json.dumps(params, ensure_ascii=False, encoding="utf8") print str_params cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, self.phone) self.session.cookies = cookies self.resp = self.session.post(url=url, data=params) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") #logging.info(url + lianjiefu + self.resp.content + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) if result["data"]: #["notCorrectJobList"]: # bearWord_timelineId = self.redis.str_set("bearWord_timelineId", # result["data"]["notCorrectJobList"][0]["timelineId"]) if result["data"]["submitUpdateDate"] != "": return [result["data"]["submitUpdateDate"]] else: print u"当前教师未存在待批改作业" raise Exception, u"当前教师未存在待批改作业"
def test_03_bear_student_courseList(self): """课程列表接口-已登录(存在课程)<br>https://mobile.yunshuxie.com/v1/bear/student/courseList.htm<br/>{"page":"1","isApp":"1"}""" cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, user=self.phone_Exist_Course) #进行登录展示接口_新用户 self.session.cookies = cookies url = r"https://mobile.yunshuxie.com" + "/v1/bear/student/courseList.htm" params = {"page": "1", "isApp": "2"} #logging.info(url + lianjiefu + json.dumps(params, ensure_ascii=False) + fengefu) str_params = json.dumps(params, ensure_ascii=False, encoding="utf8") print str_params self.resp = self.session.post(url=url, data=params) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") #logging.info(url + lianjiefu + self.resp.content + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) if result["data"]["list"]: return [result["data"]["list"][0]["productCourseId"]]
def test_03_bear_student_myWorkList(self): """用户登录-我的作品展示列表<br>http://mobile.yunshuxie.com/v1/bear/student/myWorkList.htm<br/>{"type":"2"未点评,"page":"1"}""" url = r"http://mobile.yunshuxie.com" + r"/v1/bear/student/myWorkList.htm" params = {"type": "2", "page": "1"} cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, user=self.phone) # logging.info(url + lianjiefu + json.dumps(params, ensure_ascii=False) + fengefu) str_params = json.dumps(params, ensure_ascii=False, encoding="utf8") print str_params self.resp = requests.post(url=url, headers=self.header, cookies=cookies, data=params) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") # logging.info(url + lianjiefu + self.resp.text + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"])
def test_14_v1_bear_teacher_save_correction_records(self, getKey): """老师端:批改作业保存<br>https://mobile.yunshuxie.com/v1/bear/teacher/save_correction_records.htm<br>{"timeLineId":"","commentVoice":"","excellence":"","commentContent":""}""" time.sleep(10) bearWord_timelineId = getKey["bearWord_timelineId"] commentVoice = getKey["bearWord_mp3_link"] bearWord_submitUpdateDate = getKey["bearWord_submitUpdateDate"] if bearWord_timelineId and commentVoice: url = r"https://mobile.yunshuxie.com" + r"/v1/bear/teacher/save_correction_records.htm" header = { "Connection": "keep-alive", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "BearWord/1.0.0 (iPhone; iOS 12.3.1; Scale/3.00)" } cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, self.phone) params = { "timeLineId": bearWord_timelineId, "excellence": "0", "commentVoice": commentVoice, "commentContent": "[]", "submitUpdateDate": bearWord_submitUpdateDate } # logging.info(url + lianjiefu + json.dumps(params, ensure_ascii=False) + fengefu) str_params = json.dumps(params, ensure_ascii=False, encoding="utf8") print str_params self.resp = requests.post(url=url, data=params, cookies=cookies, headers=header) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") #logging.info(url + lianjiefu + self.resp.content + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: print u"当前教师未存在待批改作业" raise Exception, u"当前教师未存在待批改作业"
def setUpClass(self, getKey): self.env_flag = "beta" #getKey["wacc_mobile_env_flag"] self.env_num = "1" #getKey["wacc_mobile_env_num"] self.phone_Exist_Course = getKey[ "make_user_phones"] #"60000009092" #存在课程 self.timestamp = "%d" % (time.time()) self.session = requests.Session() self.header = { "Connection": "keep-alive", "Content-Type": "application/x-www-form-urlencoded", "User-Agent": "BearWord/1.0.0 (iPhone; iOS 12.3.1; Scale/3.00)" } self.msg = """\n Expect: {Expect}-*-\n Really: {Really}""" # 校验HTTP返回代码 self.session.headers = self.header cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, self.phone_Exist_Course) #进行登录展示接口_新用户 self.session.cookies = cookies
def test_11_v1_bear_teacher_get_reject_reason_list(self): """驳回理由列表<br>https://mobile.yunshuxie.com/v1/bear/teacher/get_reject_reason_list.htm<br>""" url = r"https://mobile.yunshuxie.com" + r"/v1/bear/teacher/get_reject_reason_list.htm" cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, self.phone) self.session.cookies = cookies self.resp = self.session.post(url=url) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") #logging.info(url + lianjiefu + self.resp.content + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"])
def test_03_v1_bear_main_personData(self): """App个人中心数据-是否开启通知和是否是老师<br>https://mobile.yunshuxie.com/v1/bear/main/personData.htm<br>""" url = r"https://mobile.yunshuxie.com" + r"/v1/bear/main/personData.htm" cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, self.phone) self.session.cookies = cookies self.resp = self.session.post(url=url) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") #logging.info(url + lianjiefu + self.resp.content + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"])
def test_05_v1_bear_teacher_bear_teacher(self): """罐罐熊-教师端-个人中心-接收作业开关-开启<br>https://mobile.yunshuxie.com"+r"/v1/bear/teacher/recieve_teacher.htm<br>{"recieveStatus":"1"}""" url = r"https://mobile.yunshuxie.com" + r"/v1/bear/teacher/recieve_teacher.htm" params = {"recieveStatus": "1"} # logging.info(url + lianjiefu + json.dumps(params, ensure_ascii=False) + fengefu) str_params = json.dumps(params, ensure_ascii=False, encoding="utf8") print str_params cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, self.phone) self.session.cookies = cookies self.resp = self.session.post(url=url, data=params) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") #logging.info(url + lianjiefu + self.resp.content + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"])
def test_13_v1_bear_teacher_upload_voice(self): """上传批改语音接口<br>https://mobile.yunshuxie.com/v1/bear/teacher/upload_voice.htm<br>files=binary""" url = r"https://mobile.yunshuxie.com/v1/bear/teacher/upload_voice.htm" cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, self.phone) header = { "Connection": "keep-alive", # "Content-Type": "multipart/form-data", "User-Agent": "BearWord/1.0.0 (iPhone; iOS 12.3.1; Scale/3.00)" } files = { 'file': ("mp3.amr", open(r'./app/base/pythonProject/suite/wacc-mobile/mp3.amr', 'rb'), "multipart/form-data"), } str_params = """{'file': ("mp3.amr",open(r'mp3.amr', 'rb'),"multipart/form-data")}""" # logging.info(url + lianjiefu + str_params + fengefu) print str_params self.resp = requests.post(url=url, headers=header, files=files, cookies=cookies.get_dict()) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") #logging.info(url + lianjiefu + self.resp.content + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) if result["data"]["mp3"] != "": return [result["data"]["mp3"]]
def test_15_v1_bear_teacher_corrected_record_list(self): """老师端:批改记录<br>https://mobile.yunshuxie.com/v1/bear/teacher/corrected_record_list.htm<br>{"page":"1","pageSize":"10","jobType":"0"}""" time.sleep(2) url = r"https://mobile.yunshuxie.com" + r"/v1/bear/teacher/corrected_record_list.htm" params = {"page": "1", "pageSize": "10", "jobType": "0"} # logging.info(url + lianjiefu + json.dumps(params, ensure_ascii=False) + fengefu) str_params = json.dumps(params, ensure_ascii=False, encoding="utf8") print str_params cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, self.phone) self.session.cookies = cookies self.resp = self.session.post(url=url, data=params) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") #logging.info(url + lianjiefu + self.resp.content + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"])
def test_05_bear_student_summary(self): """用户登录-查询总结语列表<br>http://mobile.yunshuxie.com/v1/bear/student/summary.htm<br/>""" url = r"http://mobile.yunshuxie.com" + r"/v1/bear/student/myWorkList.htm" cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, user=self.phone) params = {"type": "4"} self.resp = requests.post(url=url, headers=self.header, cookies=cookies, data=params) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") # logging.info(url + lianjiefu + self.resp.text + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"])
def test_06_bear_student_commentTeacher(self): """用户登录-评价老师接口<br>http://mobile.yunshuxie.com/v1/bear/student/commentTeacher.htm<br/>""" url = r"http://mobile.yunshuxie.com" + r"/v1/bear/student/myWorkList.htm" params = {"type": "1", "page": "1"} # 查看教师已点评的课程作品 cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, user=self.phone) # logging.info(url + lianjiefu + json.dumps(params, ensure_ascii=False) + fengefu) self.resp = requests.post(url=url, headers=self.header, cookies=cookies, data=params) result = json.loads(self.resp.text, encoding="utf8") # logging.info(url + lianjiefu + self.resp.text + fengefu) workId_list = [] if result["data"]["list"]: for m in result["data"]["list"]: workId_list.append(m["workId"]) # 查看课程作品,判断是否存在teacherId for workId in workId_list: url = r"http://mobile.yunshuxie.com" + "/v1/bear/student/workInfo.htm" params = { "workId": workId, "deviceId": "629a5eb2a857f86dadaa043b414984f2" } # logging.info(url + lianjiefu + json.dumps(params, ensure_ascii=False) + fengefu) str_params = json.dumps(params, ensure_ascii=False, encoding="utf8") self.resp = requests.post(url=url, headers=self.header, cookies=cookies, data=params) result = json.loads(self.resp.text, encoding="utf8") # logging.info(url + lianjiefu + self.resp.text + fengefu) if result["data"]["teacherId"] != "": workId = result["data"]["workId"] teacherId = result["data"]["teacherId"] break else: print u"未存在已点评已分配教师的作品数据" raise Exception, u"未存在已点评已分配教师的作品数据" url = r"http://mobile.yunshuxie.com" + r"/v1/bear/student/commentTeacher.htm" params = { "workId": workId, "teacherId": teacherId, "commentContent": "测试评价教师功能", "commentStar": "5", "isApp": "2" } str_params = json.dumps(params, ensure_ascii=False, encoding="utf8") print str_params #logging.info(url + lianjiefu + json.dumps(params, ensure_ascii=False) + fengefu) cookies = get_app_cookie("罐罐熊APP", self.env_flag, self.env_num, user=self.phone) self.resp = requests.post(url=url, headers=self.header, cookies=cookies, data=params) print self.resp.text result = json.loads(self.resp.text, encoding="utf8") # logging.info(url + lianjiefu + self.resp.text + fengefu) expect = {"returnCode": "0"} if result["returnCode"] == "0" or result["returnCode"] == 0: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: assert result["returnCode"] == expect[ "returnCode"], self.msg.format(Expect=expect["returnCode"], Really=result["returnCode"]) else: print u"未存在教师已点评的课程作品数据" raise Exception, u"未存在教师已点评的课程作品数据"