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


Python CourseRunFactory.build方法代码示例

本文整理汇总了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
开发者ID:mitodl,项目名称:micromasters,代码行数:12,代码来源:serializers_test.py

示例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) == ()
开发者ID:mitodl,项目名称:micromasters,代码行数:22,代码来源:utils_test.py


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