本文整理汇总了Python中branding.models.BrandingInfoConfig.save方法的典型用法代码示例。如果您正苦于以下问题:Python BrandingInfoConfig.save方法的具体用法?Python BrandingInfoConfig.save怎么用?Python BrandingInfoConfig.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类branding.models.BrandingInfoConfig
的用法示例。
在下文中一共展示了BrandingInfoConfig.save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BrandingInfoConfigTest
# 需要导入模块: from branding.models import BrandingInfoConfig [as 别名]
# 或者: from branding.models.BrandingInfoConfig import save [as 别名]
class BrandingInfoConfigTest(TestCase):
"""
Test the BrandingInfoConfig model.
"""
shard = 1
def setUp(self):
super(BrandingInfoConfigTest, self).setUp()
self.configuration_string = """{
"CN": {
"url": "http://www.xuetangx.com",
"logo_src": "http://www.xuetangx.com/static/images/logo.png",
"logo_tag": "Video hosted by XuetangX.com"
}
}"""
self.config = BrandingInfoConfig(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 = BrandingInfoConfig(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 = {
"CN": {
"url": "http://www.xuetangx.com",
"logo_src": "http://www.xuetangx.com/static/images/logo.png",
"logo_tag": "Video hosted by XuetangX.com"
}
}
self.assertEquals(self.config.get_config(), expected_config)
def test_get_not_enabled(self):
"""
Tests get configuration that is not enabled.
"""
self.config.enabled = False
self.config.save()
self.assertEquals(self.config.get_config(), {})