本文整理汇总了Python中cache.Cache.putGame方法的典型用法代码示例。如果您正苦于以下问题:Python Cache.putGame方法的具体用法?Python Cache.putGame怎么用?Python Cache.putGame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache.Cache
的用法示例。
在下文中一共展示了Cache.putGame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestCache
# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import putGame [as 别名]
class TestCache(unittest.TestCase):
def setUp(self):
self.cache = Cache()
self.cache.clear()
def testGetGame(self):
game = self.cache.getGame({'id': '105600'})
self.assertIsNone(game)
self.cache.putGame({'id': '105600', 'name': 'Terraria', 'features': ['Single-player', 'Multi-player', 'Co-op']})
game = self.cache.getGame('105600')
self.assertIsNotNone(game)
self.assertEqual(game['id'], '105600')
self.assertEqual(game['name'], 'Terraria')
self.assertItemsEqual(game['features'], ['Single-player', 'Multi-player', 'Co-op'])
def testUpdateGame(self):
game = self.cache.getGame({'id': '105600'})
self.assertIsNone(game)
self.cache.putGame({'id': '105600', 'name': 'Terraria', 'features': ['Single-player', 'Multi-player', 'Co-op'], 'test': 'test'})
self.cache.putGame({'id': '105600', 'name': 'Terraria2', 'features': []})
game = self.cache.getGame('105600')
self.assertIsNotNone(game)
self.assertEqual(game['id'], '105600')
self.assertEqual(game['name'], 'Terraria2')
self.assertItemsEqual(game['features'], [])
self.assertFalse('test' in game)
self.assertFalse('_id' in game)
self.assertEqual(self.cache.games.count(), 1)