Ejemplo n.º 1
0
class SyncHistoryTests(TestCase):
    def setUp(self):
        super(SyncHistoryTests, self).setUp()
        self.course = CourseFactory(id='edx/Demo_Course/DemoX', site=self.site)

    def test_history_not_exist(self):
        self.course.history.all().delete()
        with LogCapture(LOGGER_NAME) as log:
            call_command('sync_history_with_course')
            log.check(
                (
                    LOGGER_NAME,
                    'WARNING',
                    'History object for course with course_id: edx/Demo_Course/DemoX does not exist'
                )
            )

    def test_sync_history_data(self):
        self.course.created = self.course.created + datetime.timedelta(days=1)
        self.course.save()
        call_command('sync_history_with_course')
        course = Course.objects.get(id='edx/Demo_Course/DemoX')
        self.assertEqual(course.created, self.course.history.earliest().history_date)