當前位置: 首頁>>代碼示例>>Python>>正文


Python BrandingInfoConfig.save方法代碼示例

本文整理匯總了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(), {})
開發者ID:cmscom,項目名稱:edx-platform,代碼行數:55,代碼來源:test_models.py


注:本文中的branding.models.BrandingInfoConfig.save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。