Exemple #1
0
    def test_expire_in_progress_sessions_past_due_only_not_dued(self):
        # now_datetime <= grading_rule.due
        fake_grading_rule = self.get_hacked_session_grading_rule(
            due=now() + timedelta(days=1))
        with mock.patch("course.flow.get_session_grading_rule") as \
                mock_get_grading_rule:
            mock_get_grading_rule.return_value = fake_grading_rule

            expire_in_progress_sessions(self.gopp.course.id,
                                        self.gopp.flow_id,
                                        rule_tag=None,
                                        now_datetime=now(),
                                        past_due_only=True)

        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=True).count(),
            self.in_progress_sessions_count)

        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=False).count(),
            self.ended_sessions_count)

        self.assertEqual(self.mock_update_state.call_count,
                         self.in_progress_sessions_count)

        self.assertEqual(self.mock_update_state.call_count,
                         self.in_progress_sessions_count)
Exemple #2
0
    def test_expire_in_progress_sessions_past_due_only_not_dued(self):
        # now_datetime <= grading_rule.due
        fake_grading_rule = self.get_hacked_session_grading_rule(
            due=now() + timedelta(days=1))
        with mock.patch("course.flow.get_session_grading_rule") as \
                mock_get_grading_rule:
            mock_get_grading_rule.return_value = fake_grading_rule

            expire_in_progress_sessions(
                self.gopp.course.id, self.gopp.flow_id,
                rule_tag=None, now_datetime=now(),
                past_due_only=True)

        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=True).count(),
            self.in_progress_sessions_count)

        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=False).count(),
            self.ended_sessions_count)

        self.assertEqual(self.mock_update_state.call_count,
                         self.in_progress_sessions_count)

        self.assertEqual(
            self.mock_update_state.call_count, self.in_progress_sessions_count)
Exemple #3
0
    def test_expire_in_progress_sessions(self):
        with mock.patch("course.tasks.Course.objects.get")\
                as mock_course_object_get:

            # This is to avoid errors
            mock_course_object_get.return_value = self.course

            expire_in_progress_sessions(self.course.pk,
                                        self.flow_id,
                                        rule_tag=None,
                                        now_datetime=now(),
                                        past_due_only=True)
            mock_course_object_get.assert_called_once_with(id=self.course.pk)
Exemple #4
0
    def test_expire_in_progress_sessions(self):
        with mock.patch("course.tasks.Course.objects.get")\
                as mock_course_object_get:

            # This is to avoid errors
            mock_course_object_get.return_value = self.course

            expire_in_progress_sessions(
                self.course.pk, self.flow_id,
                rule_tag=None, now_datetime=now(),
                past_due_only=True
            )
            mock_course_object_get.assert_called_once_with(id=self.course.pk)
Exemple #5
0
    def test_expire_in_progress_sessions_all(self):
        expire_in_progress_sessions(self.gopp.course.id,
                                    self.gopp.flow_id,
                                    rule_tag=None,
                                    now_datetime=now(),
                                    past_due_only=False)

        # no in_progress sessions
        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=True).count(), 0)

        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=False).count(),
            self.all_sessions_count)
Exemple #6
0
    def test_expire_in_progress_sessions_all(self):
        expire_in_progress_sessions(
            self.gopp.course.id, self.gopp.flow_id,
            rule_tag=None, now_datetime=now(),
            past_due_only=False)

        # no in_progress sessions
        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=True).count(),
            0)

        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=False).count(),
            self.all_sessions_count)
Exemple #7
0
    def test_expire_in_progress_sessions_past_due_only_due_none(self):
        # grading_rule.due is None
        expire_in_progress_sessions(
            self.gopp.course.id, self.gopp.flow_id,
            rule_tag=None, now_datetime=now(),
            past_due_only=True)

        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=True).count(),
            self.in_progress_sessions_count)

        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=False).count(),
            self.ended_sessions_count)
Exemple #8
0
    def test_expire_in_progress_sessions_past_due_only_dued(self):
        # now_datetime > grading_rule.due
        with mock.patch("course.flow.get_session_grading_rule") as \
                mock_get_grading_rule:
            mock_get_grading_rule.side_effect = (
                get_session_grading_rule_1_day_due_side_effect)
            expire_in_progress_sessions(self.gopp.course.id,
                                        self.gopp.flow_id,
                                        rule_tag=None,
                                        now_datetime=now() + timedelta(days=3),
                                        past_due_only=True)

        # no in_progress sessions
        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=True).count(), 0)

        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=False).count(),
            self.all_sessions_count)
Exemple #9
0
    def test_expire_in_progress_sessions_past_due_only_not_dued(self):
        # now_datetime <= grading_rule.due
        with mock.patch("course.flow.get_session_grading_rule") as \
                mock_get_grading_rule:
            mock_get_grading_rule.side_effect = (
                get_session_grading_rule_1_day_due_side_effect)

            expire_in_progress_sessions(
                self.gopp.course.id, self.gopp.flow_id,
                rule_tag=None, now_datetime=now(),
                past_due_only=True)

        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=True).count(),
            self.in_progress_sessions_count)

        self.assertEqual(
            models.FlowSession.objects.filter(in_progress=False).count(),
            self.ended_sessions_count)