def test_multiple_published_course_runs(self): """ Learner should not be eligible for one click purchase if: - program has a course with more than one published course run """ course_run_1 = CourseRunFactory(key=str(ModuleStoreCourseFactory().id), status='published') course_run_2 = CourseRunFactory(key=str(ModuleStoreCourseFactory().id), status='published') course = CourseFactory(course_runs=[course_run_1, course_run_2]) program = ProgramFactory( courses=[ CourseFactory(course_runs=[ CourseRunFactory(key=str(ModuleStoreCourseFactory().id), status='published') ]), course, CourseFactory(course_runs=[ CourseRunFactory(key=str(ModuleStoreCourseFactory().id), status='published') ]) ], is_program_eligible_for_one_click_purchase=True, applicable_seat_types=['verified']) data = ProgramDataExtender(program, self.user).extend() self.assertFalse(data['is_learner_eligible_for_one_click_purchase']) course_run_2['status'] = 'unpublished' data = ProgramDataExtender(program, self.user).extend() self.assertTrue(data['is_learner_eligible_for_one_click_purchase'])
def setUpClass(cls): super().setUpClass() cls.user = UserFactory() modulestore_course = ModuleStoreCourseFactory() course_run = CourseRunFactory(key=str(modulestore_course.id)) course = CourseFactory(course_runs=[course_run]) enterprise_customer = EnterpriseCustomerFactory(uuid=cls.enterprise_uuid) enterprise_customer_user = EnterpriseCustomerUserFactory( user_id=cls.user.id, enterprise_customer=enterprise_customer ) CourseEnrollmentFactory( is_active=True, course_id=modulestore_course.id, user=cls.user ) EnterpriseCourseEnrollmentFactory( course_id=modulestore_course.id, enterprise_customer_user=enterprise_customer_user ) cls.program = ProgramFactory( uuid=cls.program_uuid, courses=[course], title='Journey to cooking', type='MicroMasters', authoring_organizations=[{ 'key': 'MAX', 'logo_image_url': 'http://test.org/media/organization/logos/test-logo.png' }], ) cls.site = SiteFactory(domain='test.localhost')
def setUpClass(cls): super().setUpClass() modulestore_course = ModuleStoreCourseFactory() course_run = CourseRunFactory(key=str(modulestore_course.id)) course = CourseFactory(course_runs=[course_run]) cls.program = ProgramFactory(uuid=cls.program_uuid, courses=[course])
def setUpClass(cls): super(TestProgramDetails, cls).setUpClass() modulestore_course = ModuleStoreCourseFactory() course_run = CourseRunFactory(key=unicode(modulestore_course.id)) # pylint: disable=no-member course = CourseFactory(course_runs=[course_run]) cls.data = ProgramFactory(uuid=cls.program_uuid, courses=[course])
def setUp(self): super(TestProgramDataExtender, self).setUp() self.course = ModuleStoreCourseFactory() self.course.start = datetime.datetime.now(utc) - datetime.timedelta(days=1) self.course.end = datetime.datetime.now(utc) + datetime.timedelta(days=1) self.course = self.update_course(self.course, self.user.id) self.course_run = CourseRunFactory(key=unicode(self.course.id)) self.catalog_course = CourseFactory(course_runs=[self.course_run]) self.program = ProgramFactory(courses=[self.catalog_course])
def setUpClass(cls): super(TestProgramListing, cls).setUpClass() cls.course = ModuleStoreCourseFactory() course_run = CourseRunFactory(key=six.text_type(cls.course.id)) course = CourseFactory(course_runs=[course_run]) cls.first_program = ProgramFactory(courses=[course]) cls.second_program = ProgramFactory(courses=[course]) cls.data = sorted([cls.first_program, cls.second_program], key=cls.program_sort_key)
def setUpClass(cls): super().setUpClass() cls.course = ModuleStoreCourseFactory() course_run = CourseRunFactory(key=str(cls.course.id)) # lint-amnesty, pylint: disable=no-member course = CourseFactory(course_runs=[course_run]) cls.first_program = ProgramFactory(courses=[course]) cls.second_program = ProgramFactory(courses=[course]) cls.data = sorted([cls.first_program, cls.second_program], key=cls.program_sort_key)
def setUpClass(cls): super().setUpClass() modulestore_course = ModuleStoreCourseFactory() course_run = CourseRunFactory(key=str(modulestore_course.id)) # lint-amnesty, pylint: disable=no-member course = CourseFactory(course_runs=[course_run]) cls.program_data = ProgramFactory(uuid=cls.program_uuid, courses=[course]) cls.pathway_data = PathwayFactory() cls.program_data['pathway_ids'] = [cls.pathway_data['id']] cls.pathway_data['program_uuids'] = [cls.program_data['uuid']] del cls.pathway_data['programs'] # lint-amnesty, pylint: disable=unsupported-delete-operation
def setUpClass(cls): super(TestProgramDetails, cls).setUpClass() modulestore_course = ModuleStoreCourseFactory() course_run = CourseRunFactory(key=six.text_type(modulestore_course.id)) course = CourseFactory(course_runs=[course_run]) cls.program_data = ProgramFactory(uuid=cls.program_uuid, courses=[course]) cls.pathway_data = PathwayFactory() cls.program_data['pathway_ids'] = [cls.pathway_data['id']] cls.pathway_data['program_uuids'] = [cls.program_data['uuid']] del cls.pathway_data['programs']
def setUpClass(cls): super(TestProgramDetails, cls).setUpClass() modulestore_course = ModuleStoreCourseFactory() course_run = CourseRunFactory(key=unicode(modulestore_course.id)) # pylint: disable=no-member course = CourseFactory(course_runs=[course_run]) cls.program_data = ProgramFactory(uuid=cls.program_uuid, courses=[course]) cls.pathway_data = CreditPathwayFactory() cls.program_data['pathway_ids'] = [cls.pathway_data['id']] cls.pathway_data['program_uuids'] = [cls.program_data['uuid']] del cls.pathway_data['programs']
def test_course_pricing_when_all_course_runs_have_no_seats(self): # Create three seatless course runs and add them to the program course_runs = [] for __ in range(3): course = ModuleStoreCourseFactory() course = self.update_course(course, self.user.id) course_runs.append(CourseRunFactory(key=unicode(course.id), seats=[])) program = ProgramFactory(courses=[CourseFactory(course_runs=course_runs)]) data = ProgramMarketingDataExtender(program, self.user).extend() self.assertEqual(data['number_of_courses'], len(program['courses'])) self.assertEqual(data['full_program_price'], 0.0) self.assertEqual(data['avg_price_per_course'], 0.0)
def _create_course(self, course_price): """ Creates the course in mongo and update it with the instructor data. Also creates catalog course with respect to course run. Returns: Catalog course dict. """ course = ModuleStoreCourseFactory() course.start = datetime.datetime.now(utc) - datetime.timedelta(days=1) course.end = datetime.datetime.now(utc) + datetime.timedelta(days=1) course.instructor_info = self.instructors course = self.update_course(course, self.user.id) course_run = CourseRunFactory(key=unicode(course.id), seats=[SeatFactory(price=course_price)]) return CourseFactory(course_runs=[course_run])
def setUp(self): super(TestProgramDataExtender, self).setUp() self.user = UserFactory() self.client.login(username=self.user.username, password=self.password) self.course = ModuleStoreCourseFactory() self.course.start = datetime.datetime.now(utc) - datetime.timedelta( days=1) self.course.end = datetime.datetime.now(utc) + datetime.timedelta( days=1) self.course = self.update_course(self.course, self.user.id) # pylint: disable=no-member organization = OrganizationFactory() course_run = CourseRunFactory(key=unicode(self.course.id)) # pylint: disable=no-member course = CourseFactory(course_runs=[course_run]) program = ProgramFactory(authoring_organizations=[organization], courses=[course]) self.program = munge_catalog_program(program) self.course_code = self.program['course_codes'][0] self.run_mode = self.course_code['run_modes'][0]