本文整理汇总了Python中courses.factories.CourseRunFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python CourseRunFactory.build方法的具体用法?Python CourseRunFactory.build怎么用?Python CourseRunFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类courses.factories.CourseRunFactory
的用法示例。
在下文中一共展示了CourseRunFactory.build方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_serialized_semester_value
# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import build [as 别名]
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
示例2: test_get_year_season_from_course_run
# 需要导入模块: from courses.factories import CourseRunFactory [as 别名]
# 或者: from courses.factories.CourseRunFactory import build [as 别名]
def test_get_year_season_from_course_run(self):
"""
Tests that year/season is calculated appropriately from a CourseRun
"""
fall_2016_dt = datetime(2016, 10, 1, tzinfo=pytz.UTC)
test_run1 = CourseRunFactory.build(edx_course_key='course-v1:MITx+CTL.SC0x+1T2016', start_date=fall_2016_dt)
test_run2 = CourseRunFactory.build(edx_course_key='MITx/14.73x_1/1T2016', start_date=fall_2016_dt)
test_run3 = CourseRunFactory.build(edx_course_key='MITx/14.73x_1', start_date=fall_2016_dt)
test_run4 = CourseRunFactory.build(edx_course_key='invalid', start_date=fall_2016_dt)
unparseable_test_run1 = CourseRunFactory.build(edx_course_key='invalid', start_date=None)
unparseable_test_run2 = CourseRunFactory.build(
edx_course_key='course-v1:MITX+MITx_Digital_learning_300+3Tabc',
start_date=None
)
assert get_year_season_from_course_run(test_run1) == (2016, 'Spring')
assert get_year_season_from_course_run(test_run2) == (2016, 'Spring')
assert get_year_season_from_course_run(test_run3) == (2016, 'Fall')
assert get_year_season_from_course_run(test_run4) == (2016, 'Fall')
assert get_year_season_from_course_run(unparseable_test_run1) == ()
assert get_year_season_from_course_run(unparseable_test_run2) == ()