def test_down_check(self): student = Student(id='17373456') student.save() course = Course(bid='111') course.save() evaluation = CourseEvaluation(course=course, student=student) evaluation.save() self.assertEqual(down_check(student, evaluation), False)
def test_student_course_relation(self): student = Student(id='17373456') student.save() course = Course(bid='111', name='计算机网络', credit='2.0', hours='32', department='计算机学院', type='核心专业类') course.save() infos = ['111', '计算机网络', '(一)305', '荣文戈, 张辉', '1-16', '周1 第3,4节'] add_student_course(student=student, semester='2020_Spring', info=infos) self.assertEqual(True, True)
def test_up_count(self): student = Student(id='17373456') student.save() course = Course(bid='111') course.save() evaluation = CourseEvaluation(course=course, student=student) evaluation.save() self.assertEqual(up_count(evaluation), 0)
def test_post3(self): client = Client() student = Student(id='17373010', name='xxx', usr_name='xxx', usr_password='******', grade='2') student.save() response = client.post("/timetable/", content_type='application/json', data={"student_id": "17373010", "info": [["111", "(一)305", "荣文戈", "1-16", "周1 第3,4节"]]}) self.assertEqual(response.status_code, 400)
def test_course_evaluations_put(self): client = Client() student = Student(id='17373010') student.save() course = Course(bid='111') course.save() data = {"bid": "111", "text": "233", "score": 3, "student_id": "17373010"} response = client.put("/timetable/evaluation/student/", content_type='application/json', data=data) self.assertEqual(response.status_code, 201)
def test_up_check_teacher(self): student = Student(id='17373456') student.save() course = Course(bid='111') course.save() teacher = Teacher(name='张辉') teacher.save() teacher_course = TeacherCourse(teacher_id=teacher, course_id=course) self.assertEqual(up_check_teacher(student, teacher_course), 0)
def test_format_serializer(self): student = Student(id='17373456') student.save() course = Course(bid='111') course.save() evaluation = CourseEvaluation(course=course, student=student) evaluation.save() result = [{"id": 1, "up": 1, "down": 1}] format_serializer(result, student) self.assertEqual(True, True)
def test_course_evaluations_delete(self): client = Client() student = Student(id='17373456') student.save() course = Course(bid='111') course.save() evaluation = CourseEvaluation(course=course, student=student) evaluation.save() data = {"student_id": "17373456", "bid": "111"} response = client.delete("/timetable/evaluation/student/", content_type='application/json', data=data) self.assertEqual(response.status_code, 204)
def test_down_action(self): actor = Student(id='17373010', usr_name='111') actor.save() student = Student(id='17373456') student.save() course = Course(bid='111') course.save() evaluation = CourseEvaluation(course=course, student=student) evaluation.save() result = down_action(evaluation, actor) self.assertEqual(result.status_code, 201)
def test_format_serializer_teacher(self): student = Student(id='17373456') student.save() course = Course(bid='111') course.save() teacher = Teacher(name='张辉') teacher.save() teacher_course = TeacherCourse(teacher_id=teacher, course_id=course) teacher_course.save() format_serializer_teacher([{"id": 1}], student) self.assertEqual(True, True)
def test_course_evaluations_get(self): client = Client() student = Student(id='17373010', usr_name='111') student.save() student = Student(id='17373456') student.save() course = Course(bid='111') course.save() evaluation = CourseEvaluation(course=course, student=student) evaluation.save() response = client.get('/timetable/evaluation/student/?bid=111&student_id=17373010') self.assertEqual(response.status_code, 200)
def test_evaluation_teacher_up(self): client = Client() actor = Student(id='17373010', usr_name='111') actor.save() course = Course(bid='111', name='计算机网络', credit='2.0', hours='32', department='计算机学院', type='核心专业类') course.save() teacher = Teacher(name='张辉') teacher.save() add_teacher_relation(teacher, course) data = {"teacher": "张辉", "bid": "111", "actor": "17373010", "action": "up"} response = client.post("/timetable/evaluation/teacher/", content_type='application/json', data=data) self.assertEqual(response.status_code, 201)
def test_get_evaluation(self): student = Student(id='17373010', usr_name='111') student.save() student = Student(id='17373456') student.save() course = Course(bid='111') course.save() evaluation = CourseEvaluation(course=course, student=student) evaluation.save() actor, return_evaluation = get_evaluation({'student_id': '17373456', 'bid': '111', 'actor': '17373010'}) actor.save() self.assertEqual(return_evaluation, evaluation)
def test_evaluation_down_action(self): client = Client() student = Student(id='17373010', usr_name='111') student.save() student = Student(id='17373456') student.save() course = Course(bid='111') course.save() evaluation = CourseEvaluation(course=course, student=student) evaluation.save() data = {"student_id": "17373456", "bid": "111", "actor": "17373010"} response = client.post("/timetable/evaluation/student/down/", content_type='application/json', data=data) self.assertEqual(response.status_code, 201)
def test_search_default(self): client = Client() student = Student(id='17373010') student.save() course = Course(bid='111', name='计算机网络', credit='2.0', hours='32', department='计算机学院', type='核心专业类') course.save() teacher = Teacher(name='张辉') teacher.save() add_teacher_relation(teacher, course) infos = ['111', '计算机网络', '(一)305', '荣文戈, 张辉', '1-16', '周1 第3,4节'] add_student_course(student=student, semester='2020_Spring', info=infos) response = client.get('/timetable/search/default/?student_id=17373010') self.assertEqual(response.status_code, 200)
def test_e_cancel_up_action(self): client = Client() actor = Student(id='17373010', usr_name='111') actor.save() student = Student(id='17373456') student.save() course = Course(bid='111') course.save() evaluation = CourseEvaluation(course=course, student=student) evaluation.save() up_record = EvaluationUpRecord(evaluation=evaluation, student=actor) up_record.save() data = {"student_id": "17373456", "bid": "111", "actor": "17373010"} response = client.post("/timetable/evaluation/student/cancel_up/", content_type='application/json', data=data) self.assertEqual(response.status_code, 201)
def test_course_delete(self): client = Client() student = Student(id='17373010') student.save() course = Course(bid='111', name='计算机网络', credit='2.0', hours='32', department='计算机学院', type='核心专业类') course.save() teacher = Teacher(name='张辉') teacher.save() add_teacher_relation(teacher, course) infos = ['111', '计算机网络', '(一)305', '荣文戈, 张辉', '1-16', '周1 第3,4节'] add_student_course(student=student, semester='2020_Spring', info=infos) data = {"bid": "111", "text": "233", "score": 3, "student_id": "17373010"} client.put("/timetable/evaluation/student/", content_type='application/json', data=data) data = {"ack": "sure"} client.delete("/timetable/", content_type='application/json', data=data) self.assertEqual(Student.objects.all().count(), 1) self.assertEqual(Course.objects.all().count(), 0) self.assertEqual(StudentCourse.objects.all().count(), 0) self.assertEqual(StudentCourse.objects.all().count(), 0) self.assertEqual(CourseEvaluation.objects.all().count(), 0)
def test_get_success(self): client = Client() student = Student(id='17373010', name='xxx', usr_name='xxx', usr_password='******', grade='2') student.save() response = client.get("/timetable/?student_id=17373010&week=all") self.assertEqual(response.status_code, 200)