本文整理汇总了Python中courses.factories.CourseRunFactory类的典型用法代码示例。如果您正苦于以下问题:Python CourseRunFactory类的具体用法?Python CourseRunFactory怎么用?Python CourseRunFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CourseRunFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: two_no_show_exam_attempts
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',
)
示例2: base_test_data
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
)
示例3: create_paid_but_no_enrollable_run
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'
)
示例4: failed_run_missed_payment_can_reenroll
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)
示例5: missed_payment_can_reenroll
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)
示例6: test_serialized_semester_value
def test_serialized_semester_value(self):
"""
Tests that semester information in a course run is serialized to the right values
"""
valid_semester_course_run = CourseRunFactory.build(start_date=datetime(2017, 1, 1, tzinfo=pytz.UTC))
no_semester_course_run = CourseRunFactory.build(start_date=None, edx_course_key='bad_key')
valid_semester_serialized = UserProgramSearchSerializer.serialize_semester(valid_semester_course_run)
no_semester_serialized = UserProgramSearchSerializer.serialize_semester(no_semester_course_run)
assert valid_semester_serialized == '2017 - Spring'
assert no_semester_serialized is None
示例7: test_course_fuzzy_start_date
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'
示例8: test_course_run_finder_success
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])
示例9: setUpTestData
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)
示例10: setUpTestData
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
)
示例11: create_missed_payment_for_exam
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
)
示例12: test_course_keys
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]])
示例13: test_user_has_redemptions_left
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)
示例14: test_create_final_grade_fa
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()
示例15: create_passed_and_offered_course_run
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)