def setUp(self): super().setUp() self.pk_generator = itertools.count(1) stored_site, created = Site.objects.get_or_create( # pylint: disable=unused-variable domain='example.com') self.default_partner = Partner.objects.create(site=stored_site, name='edX', short_code='edx') SeatType.objects.all().delete() ProgramType.objects.all().delete() self.partner = PartnerFactory(name='Test') self.organization = OrganizationFactory(partner=self.partner) self.seat_type_verified = SeatTypeFactory(name='Verified', slug='verified') self.program_type_masters = ProgramTypeFactory( name='Masters', name_t='Masters', slug='masters', applicable_seat_types=[self.seat_type_verified]) self.program_type_masters_translation = self.program_type_masters.translations.all( )[0] self.program_type_mm = ProgramTypeFactory( name='MicroMasters', name_t='MicroMasters', slug='micromasters', applicable_seat_types=[self.seat_type_verified]) self.program_type_mm_translation = self.program_type_mm.translations.all( )[0] self.course = CourseFactory( partner=self.partner, authoring_organizations=[self.organization]) self.course_run = CourseRunFactory(course=self.course) self.program = ProgramFactory( type=self.program_type_masters, partner=self.partner, authoring_organizations=[self.organization]) self.course_mm = CourseFactory( partner=self.partner, authoring_organizations=[self.organization]) self.course_run_mm = CourseRunFactory(course=self.course) self.program_mm = ProgramFactory( type=self.program_type_mm, partner=self.partner, authoring_organizations=[self.organization], courses=[self.course_mm]) self.curriculum = CurriculumFactory(program=self.program) self.curriculum_course_membership = CurriculumCourseMembershipFactory( course=self.course, curriculum=self.curriculum) self.curriculum_program_membership = CurriculumProgramMembershipFactory( program=self.program_mm, curriculum=self.curriculum) self.program_2 = ProgramFactory( type=self.program_type_masters, partner=self.partner, authoring_organizations=[self.organization]) self._mock_oauth_request()
def create_program(self, orgs): program = ProgramFactory( authoring_organizations=orgs, type=self.program_type ) curr = CurriculumFactory(program=program) course1_draft = CourseFactory(draft=True) course1 = CourseFactory(draft_version=course1_draft) _run1a = CourseRunFactory(course=course1) _run1b = CourseRunFactory(course=course1) course2 = CourseFactory() _run2a = CourseRunFactory(course=course2) run2b = CourseRunFactory(course=course2) _mem1 = CurriculumCourseMembershipFactory(curriculum=curr, course=course1) mem2 = CurriculumCourseMembershipFactory(curriculum=curr, course=course2) _ex = CurriculumCourseRunExclusionFactory(course_membership=mem2, course_run=run2b) return program
def create_curriculum(self, parent_program): person = PersonFactory() course = CourseFactory(partner=self.partner) CourseRunFactory(course=course, staff=[person]) CourseRunFactory(course=course, staff=[person]) curriculum = CurriculumFactory(program=parent_program) CurriculumCourseMembershipFactory(course=course, curriculum=curriculum) return curriculum
def test_update_existing_data(self): fixture = json_serializer.Serializer().serialize([ self.organization, self.seat_type_verified, self.program_type_masters, self.program, self.curriculum, self.course, self.course_run, self.curriculum_course_membership, ]) self._mock_fixture_response(fixture) self._call_load_program_fixture([str(self.program.uuid)]) self.program.title = 'program-title-modified' self.course.title = 'course-title-modified' new_course = CourseFactory(partner=self.partner, authoring_organizations=[self.organization]) new_course_run = CourseRunFactory(course=new_course) new_course_membership = CurriculumCourseMembershipFactory( course=new_course, curriculum=self.curriculum) fixture = json_serializer.Serializer().serialize([ self.organization, self.seat_type_verified, self.program_type_masters, self.program, self.curriculum, self.course, self.course_run, self.curriculum_course_membership, new_course_membership, new_course, new_course_run, ]) responses.reset() self._mock_oauth_request() self._mock_fixture_response(fixture) self.reset_db_state() self._call_load_program_fixture([str(self.program.uuid)]) stored_program = Program.objects.get(uuid=self.program.uuid) self.assertEqual(stored_program.title, 'program-title-modified') stored_program_courses = stored_program.curricula.first( ).course_curriculum.all() modified_existing_course = stored_program_courses.get( uuid=self.course.uuid) stored_new_course = stored_program_courses.get(uuid=new_course.uuid) self.assertEqual(len(stored_program_courses), 2) self.assertEqual(modified_existing_course.title, 'course-title-modified') self.assertEqual(stored_new_course.key, new_course.key)