コード例 #1
0
ファイル: test_admin.py プロジェクト: wisnercelucus/relate
    def test_flowpagevisit_flow_id_filter_result(self):
        modeladmin = admin.FlowPageVisitAdmin(models.FlowPageVisit, site)

        for user in [self.superuser, self.instructor1, self.instructor2]:
            with self.subTest(user=user):
                request = self.rf.get(
                    self.get_admin_course_change_list_view_url(
                        "FlowPageVisit"), {})
                request.user = user
                changelist = self.get_changelist(request, models.FlowPageVisit,
                                                 modeladmin)

                filterspec_list = self.get_filterspec_list(request, changelist)

                if request.user == self.superuser:
                    self.assertIn(('All', "001-linalg-recap", QUIZ_FLOW_ID),
                                  filterspec_list)
                elif request.user == self.instructor1:
                    self.assertNotIn(('All', "001-linalg-recap", QUIZ_FLOW_ID),
                                     filterspec_list)
                    self.assertNotIn(('All', QUIZ_FLOW_ID), filterspec_list)
                    self.assertNotIn((QUIZ_FLOW_ID, ), filterspec_list)
                else:
                    assert request.user == self.instructor2
                    self.assertNotIn(('All', "001-linalg-recap", QUIZ_FLOW_ID),
                                     filterspec_list)
                    self.assertNotIn(('All', "001-linalg-recap"),
                                     filterspec_list)
                    self.assertNotIn(("001-linalg-recap", ), filterspec_list)
コード例 #2
0
ファイル: test_admin.py プロジェクト: wisnercelucus/relate
    def test_flowpagevisit_get_queryset_by_flow_id_filter(self):
        modeladmin = admin.FlowPageVisitAdmin(models.FlowPageVisit, site)

        request = self.rf.get(
            self.get_admin_course_change_list_view_url("FlowPageVisit"),
            {"flow_id": "001-linalg-recap"})
        request.user = self.instructor1
        changelist = self.get_changelist(request, models.FlowPageVisit,
                                         modeladmin)

        queryset = changelist.get_queryset(request)
        self.assertEqual(queryset.count(), self.course1_visits_count)
コード例 #3
0
ファイル: test_admin.py プロジェクト: wisnercelucus/relate
    def test_flowpagevisit_get_queryset_by_has_answer_list_filter(self):
        modeladmin = admin.FlowPageVisitAdmin(models.FlowPageVisit, site)

        request = self.rf.get(
            self.get_admin_course_change_list_view_url("FlowPageVisit"),
            {"has_answer": "y"})
        request.user = self.instructor1
        changelist = self.get_changelist(request, models.FlowPageVisit,
                                         modeladmin)

        queryset = changelist.get_queryset(request)
        self.assertEqual(queryset.count(),
                         self.course1_visits_has_answer_count)

        request.user = self.instructor2
        changelist = self.get_changelist(request, models.FlowPageVisit,
                                         modeladmin)
        queryset = changelist.get_queryset(request)
        self.assertEqual(queryset.count(),
                         self.course2_visits_has_answer_count)