예제 #1
0
    def test_models_course_run_mark_dirty_delete_course_run_to_be_scheduled(self):
        """
        Deleting a course run yet to be scheduled should not mark the related course page dirty.
        """
        field = random.choice(["start", "enrollment_start"])
        course_run = CourseRunFactory(**{field: None})
        self.assertTrue(course_run.direct_course.extended_object.publish("en"))
        title_obj = course_run.direct_course.extended_object.title_set.first()
        course_run.refresh_from_db()

        course_run.delete()
        title_obj.refresh_from_db()

        self.assertEqual(title_obj.publisher_state, PUBLISHER_STATE_DEFAULT)
예제 #2
0
    def test_models_course_run_mark_dirty_delete_course_run(self):
        """
        Deleting a scheduled course run should mark the related course page dirty.
        """
        course_run = CourseRunFactory()
        self.assertTrue(course_run.direct_course.extended_object.publish("en"))
        title_obj = course_run.direct_course.extended_object.title_set.first()
        course_run.refresh_from_db()

        self.assertEqual(title_obj.publisher_state, PUBLISHER_STATE_DEFAULT)

        course_run.delete()
        title_obj.refresh_from_db()

        self.assertEqual(title_obj.publisher_state, PUBLISHER_STATE_DIRTY)
예제 #3
0
    def test_models_course_run_delete_draft(self):
        """
        Deleting a draft course run that is not published should delete all its
        related translations.
        """
        course = CourseFactory(page_languages=["en", "fr"])
        course_run = CourseRunFactory(direct_course=course)
        CourseRunTranslation.objects.create(master=course_run,
                                            language_code="fr",
                                            title="mon titre")

        self.assertEqual(CourseRun.objects.count(), 1)
        self.assertEqual(CourseRunTranslation.objects.count(), 2)

        course_run.delete()

        self.assertFalse(CourseRun.objects.exists())
        self.assertFalse(CourseRunTranslation.objects.exists())
예제 #4
0
    def test_models_course_run_delete_published_cascade(self):
        """
        Deleting a draft course run that is published should delete its public
        counterpart and all its translations by cascade.
        """
        course = CourseFactory(page_languages=["en", "fr"])
        course_run = CourseRunFactory(direct_course=course)
        CourseRunTranslation.objects.create(master=course_run,
                                            language_code="fr",
                                            title="mon titre")
        self.assertTrue(course_run.direct_course.extended_object.publish("en"))
        self.assertTrue(course_run.direct_course.extended_object.publish("fr"))

        self.assertEqual(CourseRun.objects.count(), 2)
        self.assertEqual(CourseRunTranslation.objects.count(), 4)

        course_run.delete()

        self.assertFalse(CourseRun.objects.exists())
        self.assertFalse(CourseRunTranslation.objects.exists())