本文整理汇总了Python中the_tale.game.logic_storage.LogicStorage.process_cache_queue方法的典型用法代码示例。如果您正苦于以下问题:Python LogicStorage.process_cache_queue方法的具体用法?Python LogicStorage.process_cache_queue怎么用?Python LogicStorage.process_cache_queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.game.logic_storage.LogicStorage
的用法示例。
在下文中一共展示了LogicStorage.process_cache_queue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LogicStorageTests
# 需要导入模块: from the_tale.game.logic_storage import LogicStorage [as 别名]
# 或者: from the_tale.game.logic_storage.LogicStorage import process_cache_queue [as 别名]
#.........这里部分代码省略.........
meta_action_battle = meta_actions.ArenaPvP1x1.create(self.storage, self.hero_1, self.hero_2)
actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_1, _bundle_id=bundle_id, meta_action=meta_action_battle)
actions_prototypes.ActionMetaProxyPrototype.create(hero=self.hero_2, _bundle_id=bundle_id, meta_action=meta_action_battle)
self.storage._save_hero_data(self.hero_1.id)
self.storage._save_hero_data(self.hero_2.id)
self.hero_1.reload()
self.hero_2.reload()
self.assertEqual(meta_action_battle.serialize(), self.hero_1.actions.current_action.saved_meta_action.serialize())
self.assertEqual(meta_action_battle.serialize(), self.hero_2.actions.current_action.saved_meta_action.serialize())
def test_switch_caches(self):
self.assertEqual(self.storage.previous_cache, {})
self.assertEqual(self.storage.current_cache, {})
self.storage.previous_cache[1] = 2
self.storage.current_cache[3] = 4
self.storage.switch_caches()
self.assertEqual(self.storage.previous_cache, {3: 4})
self.assertEqual(self.storage.current_cache, {})
self.storage.current_cache[5] = 6
self.storage.switch_caches()
self.assertEqual(self.storage.previous_cache, {5: 6})
self.assertEqual(self.storage.current_cache, {})
def test_process_cache_queue__with_update(self):
self.assertEqual(self.storage.cache_queue, set())
self.storage.cache_queue.add(self.hero_2.id)
self.storage.cache_queue.add(self.hero_1.id)
self.storage.process_cache_queue(update_cache=True)
self.assertItemsEqual(self.storage.current_cache.keys(), (self.hero_1.cached_ui_info_key, self.hero_2.cached_ui_info_key))
self.assertEqual(self.storage.cache_queue, set())
def test_process_cache_queue__without_update(self):
self.assertEqual(self.storage.cache_queue, set())
self.storage.cache_queue.add(self.hero_2.id)
self.storage.cache_queue.add(self.hero_1.id)
self.storage.process_cache_queue(update_cache=False)
self.assertItemsEqual(self.storage.current_cache.keys(), ())
self.assertEqual(self.storage.cache_queue, set())
def test_process_cache_queue__update_cache__with_update(self):
self.assertEqual(self.storage.cache_queue, set())
self.storage.current_cache[self.hero_1.cached_ui_info_key] = 1
self.storage.current_cache[self.hero_2.cached_ui_info_key] = 2
self.storage.cache_queue.add(self.hero_2.id)
self.storage.process_cache_queue(update_cache=True)
self.assertEqual(self.storage.current_cache[self.hero_1.cached_ui_info_key], 1)