本文整理匯總了Python中openedx.features.course_duration_limits.models.CourseDurationLimitConfig.all_current_course_configs方法的典型用法代碼示例。如果您正苦於以下問題:Python CourseDurationLimitConfig.all_current_course_configs方法的具體用法?Python CourseDurationLimitConfig.all_current_course_configs怎麽用?Python CourseDurationLimitConfig.all_current_course_configs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類openedx.features.course_duration_limits.models.CourseDurationLimitConfig
的用法示例。
在下文中一共展示了CourseDurationLimitConfig.all_current_course_configs方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_all_current_course_configs
# 需要導入模塊: from openedx.features.course_duration_limits.models import CourseDurationLimitConfig [as 別名]
# 或者: from openedx.features.course_duration_limits.models.CourseDurationLimitConfig import all_current_course_configs [as 別名]
def test_all_current_course_configs(self):
# Set up test objects
for global_setting in (True, False, None):
CourseDurationLimitConfig.objects.create(enabled=global_setting, enabled_as_of=datetime(2018, 1, 1))
for site_setting in (True, False, None):
test_site_cfg = SiteConfigurationFactory.create(values={'course_org_filter': []})
CourseDurationLimitConfig.objects.create(
site=test_site_cfg.site, enabled=site_setting, enabled_as_of=datetime(2018, 1, 1)
)
for org_setting in (True, False, None):
test_org = "{}-{}".format(test_site_cfg.id, org_setting)
test_site_cfg.values['course_org_filter'].append(test_org)
test_site_cfg.save()
CourseDurationLimitConfig.objects.create(
org=test_org, enabled=org_setting, enabled_as_of=datetime(2018, 1, 1)
)
for course_setting in (True, False, None):
test_course = CourseOverviewFactory.create(
org=test_org,
id=CourseLocator(test_org, 'test_course', 'run-{}'.format(course_setting))
)
CourseDurationLimitConfig.objects.create(
course=test_course, enabled=course_setting, enabled_as_of=datetime(2018, 1, 1)
)
with self.assertNumQueries(4):
all_configs = CourseDurationLimitConfig.all_current_course_configs()
# Deliberatly using the last all_configs that was checked after the 3rd pass through the global_settings loop
# We should be creating 3^4 courses (3 global values * 3 site values * 3 org values * 3 course values)
# Plus 1 for the edX/toy/2012_Fall course
self.assertEqual(len(all_configs), 3**4 + 1)
# Point-test some of the final configurations
self.assertEqual(
all_configs[CourseLocator('7-True', 'test_course', 'run-None')],
{
'enabled': (True, Provenance.org),
'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run),
}
)
self.assertEqual(
all_configs[CourseLocator('7-True', 'test_course', 'run-False')],
{
'enabled': (False, Provenance.run),
'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run),
}
)
self.assertEqual(
all_configs[CourseLocator('7-None', 'test_course', 'run-None')],
{
'enabled': (True, Provenance.site),
'enabled_as_of': (datetime(2018, 1, 1, 5, tzinfo=pytz.UTC), Provenance.run),
}
)