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


Python CourseMetadata.validate_and_update_from_json方法代码示例

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


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

示例1: test_validate_and_update_from_json_wrong_inputs

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import validate_and_update_from_json [as 别名]
    def test_validate_and_update_from_json_wrong_inputs(self):
        # input incorrectly formatted data
        is_valid, errors, test_model = CourseMetadata.validate_and_update_from_json(
            self.course,
            {
                "advertised_start": {"value": 1, "display_name": "Course Advertised Start Date", },
                "days_early_for_beta": {"value": "supposed to be an integer",
                                        "display_name": "Days Early for Beta Users", },
                "advanced_modules": {"value": 1, "display_name": "Advanced Module List", },
            },
            user=self.user
        )

        # Check valid results from validate_and_update_from_json
        self.assertFalse(is_valid)
        self.assertEqual(len(errors), 3)
        self.assertFalse(test_model)

        error_keys = set([error_obj['model']['display_name'] for error_obj in errors])
        test_keys = set(['Advanced Module List', 'Course Advertised Start Date', 'Days Early for Beta Users'])
        self.assertEqual(error_keys, test_keys)

        # try fresh fetch to ensure no update happened
        fresh = modulestore().get_course(self.course.id)
        test_model = CourseMetadata.fetch(fresh)

        self.assertNotEqual(test_model['advertised_start']['value'], 1, 'advertised_start should not be updated to a wrong value')
        self.assertNotEqual(test_model['days_early_for_beta']['value'], "supposed to be an integer",
                            'days_early_for beta should not be updated to a wrong value')
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:31,代码来源:test_course_settings.py

示例2: test_validate_update_filtered_edxnotes_on

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import validate_and_update_from_json [as 别名]
 def test_validate_update_filtered_edxnotes_on(self):
     """
     If feature flag is on, then edxnotes must not be filtered.
     """
     # pylint: disable=unused-variable
     is_valid, errors, test_model = CourseMetadata.validate_and_update_from_json(
         self.course,
         {
             "edxnotes": {"value": "true"},
         },
         user=self.user
     )
     self.assertIn('edxnotes', test_model)
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:15,代码来源:test_course_settings.py

示例3: test_validate_update_filtered_on

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import validate_and_update_from_json [as 别名]
 def test_validate_update_filtered_on(self):
     """
     If feature flag is on, then giturl must not be filtered.
     """
     # pylint: disable=unused-variable
     is_valid, errors, test_model = CourseMetadata.validate_and_update_from_json(
         self.course,
         {
             "giturl": {"value": "http://example.com"},
         },
         user=self.user
     )
     self.assertIn('giturl', test_model)
开发者ID:uestcmooc,项目名称:edx-platform,代码行数:15,代码来源:test_course_settings.py

示例4: test_validate_from_json_correct_inputs

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import validate_and_update_from_json [as 别名]
    def test_validate_from_json_correct_inputs(self):
        is_valid, errors, test_model = CourseMetadata.validate_and_update_from_json(
            self.course,
            {
                "advertised_start": {"value": "start A"},
                "days_early_for_beta": {"value": 2},
                "advanced_modules": {"value": ['combinedopenended']},
            },
            user=self.user
        )
        self.assertTrue(is_valid)
        self.assertTrue(len(errors) == 0)
        self.update_check(test_model)

        # Tab gets tested in test_advanced_settings_munge_tabs
        self.assertIn('advanced_modules', test_model, 'Missing advanced_modules')
        self.assertEqual(test_model['advanced_modules']['value'], ['combinedopenended'], 'advanced_module is not updated')
开发者ID:Rahul-Shenoy,项目名称:edx-platform,代码行数:19,代码来源:test_course_settings.py

示例5: test_validate_and_update_from_json_correct_inputs

# 需要导入模块: from models.settings.course_metadata import CourseMetadata [as 别名]
# 或者: from models.settings.course_metadata.CourseMetadata import validate_and_update_from_json [as 别名]
    def test_validate_and_update_from_json_correct_inputs(self):
        is_valid, errors, test_model = CourseMetadata.validate_and_update_from_json(
            self.course,
            {
                "advertised_start": {"value": "start A"},
                "days_early_for_beta": {"value": 2},
                "advanced_modules": {"value": ["combinedopenended"]},
            },
            user=self.user,
        )
        self.assertTrue(is_valid)
        self.assertTrue(len(errors) == 0)
        self.update_check(test_model)

        # fresh fetch to ensure persistence
        fresh = modulestore().get_course(self.course.id)
        test_model = CourseMetadata.fetch(fresh)
        self.update_check(test_model)

        # Tab gets tested in test_advanced_settings_munge_tabs
        self.assertIn("advanced_modules", test_model, "Missing advanced_modules")
        self.assertEqual(
            test_model["advanced_modules"]["value"], ["combinedopenended"], "advanced_module is not updated"
        )
开发者ID:GeertHa,项目名称:edx-platform,代码行数:26,代码来源:test_course_settings.py


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