当前位置: 首页>>代码示例>>Python>>正文


Python CourseRunFactory.create方法代码示例

本文整理汇总了Python中courses.factories.CourseRunFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python CourseRunFactory.create方法的具体用法?Python CourseRunFactory.create怎么用?Python CourseRunFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在courses.factories.CourseRunFactory的用法示例。


在下文中一共展示了CourseRunFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: two_no_show_exam_attempts

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
    def two_no_show_exam_attempts(self):
        """Passed and later failed course, and two exam attempts"""
        self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED)

        course = Course.objects.get(title='Digital Learning 200')
        course_run = CourseRunFactory(course=course, edx_course_key='course-passed')
        call_command(
            "alter_data", 'set_to_passed', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key
        )

        ExamProfileFactory.create(status='success', profile=self.user.profile)
        # run 1
        exam_run = ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)
        ExamAuthorizationFactory.create(
            user=self.user, course=course, exam_run=exam_run, status='success', exam_taken=True, exam_no_show=True
        )
        # run 2
        exam_run = ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)
        ExamAuthorizationFactory.create(
            user=self.user, course=course, exam_run=exam_run, status='success', exam_taken=True, exam_no_show=True
        )
        # another offered
        course_run = CourseRunFactory.create(course=course, edx_course_key='course-enrollable')
        call_command(
            "alter_data", 'set_to_offered', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key
        )
        course_run = CourseRunFactory.create(course=course, edx_course_key='course-failed')
        call_command(
            "alter_data", 'set_to_failed', '--username', 'staff',
            '--course-run-key', course_run.edx_course_key, '--audit',
        )
开发者ID:mitodl,项目名称:micromasters,代码行数:35,代码来源:snapshot_dashboard_states.py

示例2: create_paid_but_no_enrollable_run

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
    def create_paid_but_no_enrollable_run(self, enrollable, in_future, fuzzy):
        """Make paid but not enrolled, with offered currently, in future, and fuzzy """
        self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED)
        course = Course.objects.get(title='Digital Learning 200')
        course_run = course.courserun_set.order_by('start_date').first()
        # course_run = CourseRunFactory.create(course=course, edx_course_key='course-paid')

        add_paid_order_for_course(user=self.user, course_run=course_run)
        if enrollable:
            course_run = CourseRunFactory.create(course=course, edx_course_key='course-enrollable')
            call_command(
                "alter_data", 'set_to_offered', '--username', 'staff',
                '--course-run-key', course_run.edx_course_key
            )
        if in_future:
            course_run = CourseRunFactory.create(course=course, edx_course_key='course-in-future')
            call_command(
                "alter_data", 'set_to_offered', '--username', 'staff',
                '--course-run-key', course_run.edx_course_key, '--in-future'
            )
        if fuzzy:
            course_run = CourseRunFactory.create(course=course, edx_course_key='course-fuzzy')
            call_command(
                "alter_data", 'set_to_offered', '--username', 'staff',
                '--course-run-key', course_run.edx_course_key, '--fuzzy'
            )
开发者ID:mitodl,项目名称:micromasters,代码行数:28,代码来源:snapshot_dashboard_states.py

示例3: base_test_data

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
def base_test_data():
    """
    Fixture for test data that should be available to any test case in the suite
    """
    # Create a live program with valid prices and financial aid
    program = ProgramFactory.create(
        live=True,
        financial_aid_availability=True,
        price=1000,
    )
    CourseRunFactory.create(course__program=program)
    TierProgramFactory.create_properly_configured_batch(2, program=program)
    # Create users
    staff_user, student_user = (create_user_for_login(is_staff=True), create_user_for_login(is_staff=False))
    ProgramEnrollment.objects.create(program=program, user=staff_user)
    ProgramEnrollment.objects.create(program=program, user=student_user)
    Role.objects.create(
        role=Staff.ROLE_ID,
        user=staff_user,
        program=program,
    )
    return SimpleNamespace(
        staff_user=staff_user,
        student_user=student_user,
        program=program
    )
开发者ID:mitodl,项目名称:micromasters,代码行数:28,代码来源:conftest.py

示例4: failed_run_missed_payment_can_reenroll

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
 def failed_run_missed_payment_can_reenroll(self):
     """Failed User has missed payment but they can re-enroll"""
     call_command(
         "alter_data", 'set_to_failed', '--username', 'staff',
         '--course-title', 'Analog Learning 200', '--grade', '0', '--audit'
     )
     course = Course.objects.get(title='Analog Learning 200')
     CourseRunFactory.create(course=course)
开发者ID:mitodl,项目名称:micromasters,代码行数:10,代码来源:snapshot_dashboard_states.py

示例5: missed_payment_can_reenroll

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
 def missed_payment_can_reenroll(self):
     """User has missed payment but they can re-enroll"""
     call_command(
         "alter_data", 'set_to_needs_upgrade', '--username', 'staff',
         '--course-title', 'Analog Learning 200', '--missed-deadline',
     )
     course = Course.objects.get(title='Analog Learning 200')
     CourseRunFactory.create(course=course)
开发者ID:mitodl,项目名称:micromasters,代码行数:10,代码来源:snapshot_dashboard_states.py

示例6: test_course_fuzzy_start_date

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
 def test_course_fuzzy_start_date(self):
     """Test course with promised course run"""
     CourseRunFactory.create(
         course=self.course,
         fuzzy_start_date="Fall 2017",
         start_date=None,
         end_date=None,
         enrollment_start=None,
         enrollment_end=None,
     )
     assert self.course.enrollment_text == 'Coming Fall 2017'
开发者ID:mitodl,项目名称:micromasters,代码行数:13,代码来源:models_test.py

示例7: test_course_run_finder_success

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
    def test_course_run_finder_success(self):
        """Tests that CourseRunFinder will return a desired course run"""
        course_run = CourseRunFactory.create(title='courserun1', edx_course_key='coursekey1')
        CourseRunFactory.create(title='courserun2', edx_course_key='coursekey2')

        found_course_runs = [
            CourseRunFinder.find(course_run_title='courserun1'),
            CourseRunFinder.find(course_run_title='run1'),
            CourseRunFinder.find(course_run_key='coursekey1'),
            CourseRunFinder.find(course_run_key='key1')
        ]
        assert all([course_run == found_course_run for found_course_run in found_course_runs])
开发者ID:mitodl,项目名称:micromasters,代码行数:14,代码来源:lib_test.py

示例8: setUpTestData

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
 def setUpTestData(cls):
     """Create a set of course runs for testing"""
     super().setUpTestData()
     cls.run1 = CourseRunFactory.create(
         course__program__live=True,
         course__program__financial_aid_availability=True,
     )
     cls.program = cls.run1.course.program
     cls.run2 = CourseRunFactory.create(course=cls.run1.course)
     cls.runs = [cls.run1, cls.run2]
     cls.user = UserFactory.create()
     ProgramEnrollment.objects.create(user=cls.user, program=cls.run1.course.program)
开发者ID:mitodl,项目名称:micromasters,代码行数:14,代码来源:api_test.py

示例9: setUpTestData

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
    def setUpTestData(cls):
        super().setUpTestData()
        # create an user
        cls.user = UserFactory.create()
        cls.cached_edx_user_data = MagicMock(
            spec=CachedEdxUserData,
            enrollments=CachedEnrollment.deserialize_edx_data(cls.enrollments_json),
            certificates=CachedCertificate.deserialize_edx_data(cls.certificates_json),
            current_grades=CachedCurrentGrade.deserialize_edx_data(cls.current_grades_json),
        )

        # create the programs
        cls.program = ProgramFactory.create(live=True, financial_aid_availability=False, price=1000)
        cls.program_financial_aid = ProgramFactory.create(live=True, financial_aid_availability=True, price=1000)

        # create course runs for the normal program
        cls.course = CourseFactory.create(program=cls.program)
        expected_course_keys = [
            "course-v1:edX+DemoX+Demo_Course",
            "course-v1:MITx+8.MechCX+2014_T1",
            '',
            None,
            'course-v1:odl+FOO102+CR-FALL16'
        ]

        cls.cruns = []
        for course_key in expected_course_keys:
            course_run = CourseRunFactory.create(
                course=cls.course,
                edx_course_key=course_key
            )
            if course_key:
                cls.cruns.append(course_run)

        # and the program with financial aid
        finaid_course = CourseFactory.create(program=cls.program_financial_aid)
        cls.now = now_in_utc()
        cls.end_date = cls.now - timedelta(weeks=45)
        cls.crun_fa = CourseRunFactory.create(
            course=finaid_course,
            start_date=cls.now-timedelta(weeks=52),
            end_date=cls.end_date,
            enrollment_start=cls.now-timedelta(weeks=62),
            enrollment_end=cls.now-timedelta(weeks=53),
            edx_course_key="course-v1:odl+FOO101+CR-FALL15"
        )
        cls.crun_fa2 = CourseRunFactory.create(
            course=finaid_course
        )
        CourseRunFactory.create(
            course=finaid_course,
            edx_course_key=None
        )
开发者ID:mitodl,项目名称:micromasters,代码行数:55,代码来源:utils_test.py

示例10: test_course_keys

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
    def test_course_keys(self):
        """
        Coupon.course_keys should return a list of all course run keys in a program, course, or course run
        """
        run1 = CourseRunFactory.create(course__program__financial_aid_availability=True)
        run2 = CourseRunFactory.create(course=run1.course)
        run3 = CourseRunFactory.create(course__program=run1.course.program)
        run4 = CourseRunFactory.create(course=run3.course)

        coupon_program = CouponFactory.create(
            content_object=run1.course.program,
        )
        assert sorted(coupon_program.course_keys) == sorted([run.edx_course_key for run in [run1, run2, run3, run4]])

        coupon_course = CouponFactory.create(content_object=run1.course)
        assert sorted(coupon_course.course_keys) == sorted([run.edx_course_key for run in [run1, run2]])
开发者ID:mitodl,项目名称:micromasters,代码行数:18,代码来源:models_test.py

示例11: create_missed_payment_for_exam

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
    def create_missed_payment_for_exam(self, enrollable, future_exam, current):
        """Passed course but missed deadline to pay to take exam"""
        self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED)
        if current:
            call_command(
                "alter_data", 'set_to_enrolled', '--username', 'staff',
                '--course-title', 'Digital Learning 200',
                '--missed-deadline'
            )
        else:
            call_command(
                "alter_data", 'set_past_run_to_passed', '--username', 'staff',
                '--course-title', 'Digital Learning 200', '--grade', '87', '--audit',
                '--missed-deadline'
            )
        course = Course.objects.get(title='Digital Learning 200')
        ExamProfileFactory.create(status='success', profile=self.user.profile)
        ExamRunFactory.create(course=course, eligibility_past=True, scheduling_past=True)

        if enrollable:
            course_run = CourseRunFactory.create(course=course, edx_course_key='course-enrollable')
            call_command(
                "alter_data", 'set_to_offered', '--username', 'staff',
                '--course-run-key', course_run.edx_course_key
            )
        if future_exam:
            ExamRunFactory.create(
                scheduling_past=False,
                scheduling_future=True,
                authorized=True,
                course=course
            )
开发者ID:mitodl,项目名称:micromasters,代码行数:34,代码来源:snapshot_dashboard_states.py

示例12: create_passed_and_offered_course_run

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
    def create_passed_and_offered_course_run(self, grades_frozen, with_certificate):
        """Make passed and currently offered course run, and see the View Certificate and Re-Enroll"""
        self.make_fa_program_enrollment(FinancialAidStatus.AUTO_APPROVED)
        call_command(
            "alter_data", 'set_to_passed', '--username', 'staff',
            '--course-title', 'Digital Learning 200', '--grade', '89',
        )
        course = Course.objects.get(title='Digital Learning 200')
        # create another currently offered run
        CourseRunFactory.create(course=course)

        if grades_frozen:
            final_grade = FinalGrade.objects.filter(user=self.user, course_run__course=course, passed=True).first()
            CourseRunGradingStatus.objects.create(course_run=final_grade.course_run, status='complete')
            if with_certificate:
                MicromastersCourseCertificate.objects.create(user=self.user, course=course)
                CourseCertificateSignatoriesFactory.create(course=course)
开发者ID:mitodl,项目名称:micromasters,代码行数:19,代码来源:snapshot_dashboard_states.py

示例13: test_create_final_grade_fa

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
 def test_create_final_grade_fa(self, generate_letter_mock, update_grade_mock, mock_on_commit):
     """
     Test that final grades created for non-FA courses will try to update combined final grades.
     """
     fa_course_run = CourseRunFactory.create(course__program__financial_aid_availability=True)
     FinalGradeFactory.create(user=self.user, course_run=fa_course_run, grade=0.9)
     update_grade_mock.assert_called_once_with(self.user, fa_course_run.course)
     generate_letter_mock.assert_not_called()
开发者ID:mitodl,项目名称:micromasters,代码行数:10,代码来源:signals_test.py

示例14: setUpTestData

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
    def setUpTestData(cls):
        cls.users = [UserFactory.create() for _ in range(35)]

        freeze_date = now_in_utc()-timedelta(days=1)
        future_freeze_date = now_in_utc()+timedelta(days=1)
        cls.course_run1 = CourseRunFactory.create(freeze_grade_date=freeze_date)
        cls.course_run2 = CourseRunFactory.create(freeze_grade_date=freeze_date)
        cls.all_freezable_runs = [cls.course_run1, cls.course_run2]

        cls.course_run_future = CourseRunFactory.create(freeze_grade_date=future_freeze_date)
        cls.course_run_frozen = CourseRunFactory.create(freeze_grade_date=freeze_date)

        CourseRunGradingStatus.objects.create(course_run=cls.course_run_frozen, status=FinalGradeStatus.COMPLETE)

        for user in cls.users:
            CachedEnrollmentFactory.create(user=user, course_run=cls.course_run1)
            CachedCurrentGradeFactory.create(user=user, course_run=cls.course_run1)
开发者ID:mitodl,项目名称:micromasters,代码行数:19,代码来源:tasks_test.py

示例15: test_user_has_redemptions_left

# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import create [as 别名]
    def test_user_has_redemptions_left(self, order_status, has_unpurchased_run, another_already_redeemed, expected):
        """
        Coupon.user_has_redemptions_left should be true if user has not yet purchased all course runs
        """
        run1 = CourseRunFactory.create(course__program__financial_aid_availability=True)
        if has_unpurchased_run:
            CourseRunFactory.create(course__program=run1.course.program)

        line = LineFactory.create(course_key=run1.edx_course_key, order__status=order_status)
        coupon = CouponFactory.create(content_object=run1.course.program)
        with patch(
            'ecommerce.models.Coupon.another_user_already_redeemed',
            autospec=True,
        ) as _already_redeemed:
            _already_redeemed.return_value = another_already_redeemed
            assert coupon.user_has_redemptions_left(line.order.user) is expected
        _already_redeemed.assert_called_with(coupon, line.order.user)
开发者ID:mitodl,项目名称:micromasters,代码行数:19,代码来源:models_test.py


注:本文中的courses.factories.CourseRunFactory.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。