예제 #1
0
    def setUp(self):
        super().setUp()

        self.recent_evals = [EvaluationFactory(), EvaluationFactory()]
        EvaluationFactory()

        db.session.flush()
예제 #2
0
    def setUp(self):
        super().setUp()
        self.section = SectionFactory()
        self.eval = EvaluationFactory(student=self.student)
        self.eval2 = EvaluationFactory()
        EvaluationFactory(student=self.student)

        db.session.flush()
예제 #3
0
    def setUp(self):
        super().setUp()

        self.section = SectionFactory()
        self.eval = EvaluationFactory(student=self.student)
        self.eval2 = EvaluationFactory(section=self.section,
                                       professor=self.section.professors[0])
        eval3 = EvaluationFactory(student=self.student)
        VoteFactory(student_id=0, evaluation=eval3)
예제 #4
0
    def setUp(self):
        self.s1 = SectionFactory()
        self.s2 = SectionFactory()
        s3 = SectionFactory()
        SectionFactory()

        EvaluationFactory(section=self.s1)
        EvaluationFactory(section=self.s1)
        EvaluationFactory(section=self.s2)
        EvaluationFactory(section=s3)
예제 #5
0
    def test_get_course_id(self):
        ev = EvaluationFactory()
        EvaluationFactory()

        rv = self.client.get('/evaluations',
                             headers=self.head_auth,
                             query_string=urlencode(
                                 {'course_id': ev.section.course_id}))

        self.assertEqual(200, rv.status_code)
        evals = json.loads(rv.data)
        self.assertEqual(1, len(evals))
예제 #6
0
    def test_get(self):
        EvaluationFactory(student=self.student)
        EvaluationFactory(student=self.student)
        EvaluationFactory()

        rv = self.client.get(
            '/students/{}/evaluations'.format(self.student.id),
            headers=self.head_auth,
            query_string=urlencode({'embed': ['professor', 'course']}, True))

        self.assertEqual(200, rv.status_code)
        evals = json.loads(rv.data)
        self.assertEqual(2, len(evals))
예제 #7
0
    def setUp(self):
        p1 = ProfessorFactory()
        p2 = ProfessorFactory()
        p3 = ProfessorFactory()
        p4 = ProfessorFactory()

        self.s1 = SectionFactory(professors=[p1])
        self.s2 = SectionFactory(professors=[p2])
        s3 = SectionFactory(professors=[p3])
        SectionFactory(professors=[p4])

        EvaluationFactory(section=self.s1, professor=p1)
        EvaluationFactory(section=self.s2, professor=p2)
        EvaluationFactory(section=s3, professor=p3)
예제 #8
0
    def test_post_evaluation_duplicate(self):
        data = {
            'quarter_id': self.section.quarter_id,
            'professor_id': self.section.professors[0].id,
            'course_id': self.section.course_id,
            'display_grad_year': True,
            'display_majors': False,
            'evaluation': {
                'attitude': 1,
                'availability': 1,
                'clarity': 1,
                'easiness': 1,
                'grading_speed': 1,
                'recommended': 1,
                'resourcefulness': 1,
                'workload': 1,
                'comment': 'Test'
            }
        }

        EvaluationFactory(section=self.section,
                          professor=self.section.professors[0],
                          student=self.student)

        rv = self.client.post('/evaluations',
                              headers=self.head_auth_json,
                              data=json.dumps(data))
        self.assertEqual(409, rv.status_code)
예제 #9
0
    def setUp(self):
        super().setUp()

        self.course = CourseFactory()
        prof = ProfessorFactory()
        prof2 = ProfessorFactory()
        prof3 = ProfessorFactory()
        student = StudentFactory()

        section = SectionFactory(course=self.course, professors=[prof, prof2, prof3])

        # prof2 has taught this course multiple quarters
        SectionFactory(course=self.course, professors=[prof2])

        EvaluationFactory(student=self.student, professor=prof, section=section)
        evaluation = EvaluationFactory(student=student, professor=prof, section=section)
        VoteFactory(student=self.student, evaluation=evaluation, value=Vote.UPVOTE)

        db.session.flush()
예제 #10
0
    def test_post_flag_invalid_reason(self):
        evaluation = EvaluationFactory()
        db.session.flush()

        data = {'reason_ids': [-1], 'comment': 'Foo'}

        rv = self.client.post('/evaluations/{}/flag'.format(evaluation.id),
                              headers=self.head_auth_json,
                              data=json.dumps(data))

        self.assertEqual(422, rv.status_code)
예제 #11
0
    def test_post_flag_own_evaluation(self):
        evaluation = EvaluationFactory(student=self.student)
        db.session.flush()

        rv = self.client.post('/evaluations/{}/flag'.format(evaluation.id),
                              headers=self.head_auth_json,
                              data=json.dumps(self.post_data))

        self.assertEqual(403, rv.status_code)
        data = json.loads(rv.data)
        self.assertIn('not allowed to flag your own evaluations',
                      data['message'])
예제 #12
0
    def test_post_flag_no_comment(self):
        evaluation = EvaluationFactory()
        db.session.flush()

        data = self.post_data
        del data['comment']

        rv = self.client.post('/evaluations/{}/flag'.format(evaluation.id),
                              headers=self.head_auth_json,
                              data=json.dumps(self.post_data))

        self.assertEqual(201, rv.status_code)
예제 #13
0
    def test_post_flag(self):
        evaluation = EvaluationFactory()
        db.session.flush()

        rv = self.client.post('/evaluations/{}/flag'.format(evaluation.id),
                              headers=self.head_auth_json,
                              data=json.dumps(self.post_data))

        self.assertEqual(201, rv.status_code)

        flags = evaluation.flags
        self.assertEqual(1, len(flags))
예제 #14
0
    def setUp(self):
        super().setUp()

        self.course = CourseFactory()
        self.prof = ProfessorFactory()
        prof2 = ProfessorFactory()
        prof3 = ProfessorFactory()
        student = StudentFactory()
        section = SectionFactory(course=self.course,
                                 professors=[self.prof, prof2, prof3])

        # prof has taught this course twice
        SectionFactory(course=self.course, professors=[self.prof])

        SectionFactory(professors=[self.prof])
        EvaluationFactory(student=self.student,
                          professor=self.prof,
                          section=section)
        evaluation = EvaluationFactory(student=student,
                                       professor=self.prof,
                                       section=section)
        VoteFactory(student=self.student, evaluation=evaluation)

        db.session.flush()