本文整理汇总了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
示例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(), {})