本文整理匯總了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(), {})