def test_course_revision_serializer_without_subjects(self): """ Verify that CourseRevisionSerializer serialize the course revision object even if subject fields are not available. """ course = CourseFactory(primary_subject=None, secondary_subject=None, tertiary_subject=None, level_type=None) course.title = 'updated title' course.save() revision = course.history.first() serializer = CourseRevisionSerializer(revision) expected = { 'history_id': revision.history_id, 'title': revision.title, 'number': revision.number, 'short_description': revision.short_description, 'full_description': revision.full_description, 'expected_learnings': revision.expected_learnings, 'prerequisites': revision.prerequisites, 'primary_subject': None, 'secondary_subject': None, 'tertiary_subject': None, 'level_type': None, 'learner_testimonial': revision.learner_testimonial, 'faq': revision.faq, 'video_link': revision.video_link } self.assertDictEqual(serializer.data, expected)
def test_course_revision_serializer(self): """ Verify that CourseRevisionSerializer serialize the course revision object. """ course = CourseFactory() course.title = 'updated title' course.save() revision = course.history.first() serializer = CourseRevisionSerializer(revision) expected = { 'history_id': revision.history_id, 'title': revision.title, 'number': revision.number, 'short_description': revision.short_description, 'full_description': revision.full_description, 'expected_learnings': revision.expected_learnings, 'prerequisites': revision.prerequisites, 'primary_subject': revision.primary_subject.name, 'secondary_subject': revision.secondary_subject.name, 'tertiary_subject': revision.tertiary_subject.name, 'level_type': revision.level_type.name } self.assertDictEqual(serializer.data, expected)