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


Python Setting._get_settings_dict方法代码示例

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


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

示例1: testMigration

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import _get_settings_dict [as 别名]
    def testMigration(self):
        from models import Setting

        # put in some old values
        self.policy.SetProbability(1)
        db.put(
            [
                Setting(key_name="test", parent=None, value="old and busted"),
                Setting(key_name="another", parent=None, value="another old value"),
            ]
        )
        Setting._get_settings_dict(bust_cache=True)
        self.policy.SetProbability(0)

        self.assertEqual(Setting._get_or_set_with_key("test"), "old and busted")
        self.assertEqual(Setting._get_or_set_with_key("another"), "another old value")

        # simulate a write
        Setting._get_or_set_with_key("test", "new hotness")

        # now assert that old and new style settings were updated
        old = Setting.get_by_key_name("test", parent=None)
        self.assertEqual(old.value, "new hotness")
        new = Setting.get_by_key_name("test", parent=Setting.entity_group_key())
        self.assertEqual(new.value, "new hotness")

        # finally, check the caching layers work too
        self.assertEqual(Setting._cache_get_by_key_name("test"), "new hotness")
        self.assertEqual(Setting._get_or_set_with_key("another"), "another old value")
开发者ID:KhanWorld,项目名称:KhanML,代码行数:31,代码来源:testsetting.py


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