Example #1
0
 def test_actual_date_schedule_after_end(self):
     # This only applies for relative dates so we are not testing abs date.
     policy = DatePolicy(rel_date=timedelta(days=1))
     schedule = DummySchedule(created=datetime(2020, 4, 1),
                              start_date=datetime(2020, 4, 1))
     self.assertIsNone(
         policy.actual_date(schedule, end_datetime=datetime(2020, 1, 1)))
Example #2
0
 def test_actual_date_schedule_after_cutoff(self):
     # This only applies for relative dates so we are not testing abs date.
     day = timedelta(days=1)
     policy = DatePolicy(rel_date=day)
     schedule = DummySchedule(start_date=datetime(2020, 4, 1))
     self.assertIsNone(
         policy.actual_date(schedule,
                            cutoff_datetime=(schedule.created - day)))
     self.assertIsNotNone(
         policy.actual_date(schedule,
                            cutoff_datetime=(schedule.created + day)))
Example #3
0
    def setUp(self):
        super(TestContentDate, self).setUp()
        self.course = DummyCourse(id='course-v1:edX+Test+Course')
        self.course.save()

        self.user = User()
        self.user.save()

        self.enrollment = DummyEnrollment(user=self.user, course=self.course)
        self.enrollment.save()

        self.schedule = DummySchedule(enrollment=self.enrollment, start_date=datetime(2020, 1, 1))
        self.schedule.save()

        self.policy = DatePolicy(abs_date=datetime(2020, 1, 1))
        self.content_date = ContentDate(course_id=self.course.id, policy=self.policy)
Example #4
0
 def test_mixed_dates(self):
     with self.assertRaises(ValidationError):
         DatePolicy(abs_date=datetime(2020, 1, 1), rel_date=timedelta(days=1)).full_clean()
Example #5
0
 def test_actual_date_failure(self, abs_date, rel_date, schedule):
     policy = DatePolicy(abs_date=abs_date, rel_date=rel_date)
     with self.assertRaises(ValueError):
         policy.actual_date(schedule)
Example #6
0
 def test_actual_date(self, abs_date, rel_date, schedule, expected):
     policy = DatePolicy(abs_date=abs_date, rel_date=rel_date)
     assert policy.actual_date(schedule) == expected