本文整理汇总了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")