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


Python CertificateHtmlViewConfiguration.save方法代码示例

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


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

示例1: _certificate_html_view_configuration

# 需要导入模块: from certificates.models import CertificateHtmlViewConfiguration [as 别名]
# 或者: from certificates.models.CertificateHtmlViewConfiguration import save [as 别名]
 def _certificate_html_view_configuration(self, configuration_string, enabled=True):
     """
     This will create a certificate html configuration
     """
     config = CertificateHtmlViewConfiguration(enabled=enabled, configuration=configuration_string)
     config.save()
     return config
开发者ID:lemontreeran,项目名称:edx-platform,代码行数:9,代码来源:test_views.py

示例2: CertificateHtmlViewConfigurationTest

# 需要导入模块: from certificates.models import CertificateHtmlViewConfiguration [as 别名]
# 或者: from certificates.models.CertificateHtmlViewConfiguration import save [as 别名]
class CertificateHtmlViewConfigurationTest(TestCase):
    """
    Test the CertificateHtmlViewConfiguration model.
    """

    def setUp(self):
        super(CertificateHtmlViewConfigurationTest, self).setUp()
        self.configuration_string = """{
            "default": {
                "url": "http://www.edx.org",
                "logo_src": "http://www.edx.org/static/images/logo.png"
            },
            "honor": {
                "logo_src": "http://www.edx.org/static/images/honor-logo.png"
            }
        }"""
        self.config = CertificateHtmlViewConfiguration(configuration=self.configuration_string)

    def test_create(self):
        """
        Tests creation of configuration.
        """
        self.config.save()
        self.assertEquals(self.config.configuration, self.configuration_string)

    def test_clean_bad_json(self):
        """
        Tests if bad JSON string was given.
        """
        self.config = CertificateHtmlViewConfiguration(configuration='{"bad":"test"')
        self.assertRaises(ValidationError, self.config.clean)

    def test_get(self):
        """
        Tests get configuration from saved string.
        """
        self.config.enabled = True
        self.config.save()
        expected_config = {
            "default": {"url": "http://www.edx.org", "logo_src": "http://www.edx.org/static/images/logo.png"},
            "honor": {"logo_src": "http://www.edx.org/static/images/honor-logo.png"},
        }
        self.assertEquals(self.config.get_config(), expected_config)

    def test_get_not_enabled_returns_blank(self):
        """
        Tests get configuration that is not enabled.
        """
        self.config.enabled = False
        self.config.save()
        self.assertEquals(len(self.config.get_config()), 0)

    @override_settings(FEATURES=FEATURES_INVALID_FILE_PATH)
    def test_get_no_database_no_file(self):
        """
        Tests get configuration that is not enabled.
        """
        self.config.configuration = ""
        self.config.save()
        self.assertEquals(self.config.get_config(), {})
开发者ID:Colin-Fredericks,项目名称:edx-platform,代码行数:62,代码来源:test_models.py


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