コード例 #1
0
ファイル: test_filters.py プロジェクト: regisb/figures
 def test_get_all_course_enrollments(self):
     f = CourseEnrollmentFilter(queryset=CourseEnrollment.objects.all())
     self.assertQuerysetEqual(
         f.qs,
         [o.id for o in self.course_enrollments],
         lambda o: o.id,
         ordered=False)
コード例 #2
0
    def test_filter_course_id(self):
        '''
        Each default factory created course enrollment has a unique course id
        We use this to get the course id for the first CourseEnrollment object
        Then we filter results on this course id and compare to the results
        returned by the filter class
        '''
        course_id = CourseEnrollment.objects.all()[0].course_id
        expected_results = CourseEnrollment.objects.filter(course_id=course_id)
        assert expected_results.count() != len(self.course_enrollments)
        f = CourseEnrollmentFilter(queryset=expected_results)

        res = CourseEnrollmentFilter().filter_course_id(
            queryset=CourseEnrollment.objects.all(),
            name='course_id',
            value=str(course_id))
        self.assertQuerysetEqual(res, [o.id for o in expected_results],
                                 lambda o: o.id,
                                 ordered=False)