def test_collection_no_prefetch_no_requests(self): coll = pyBGG.collection("Iago71", own=True, prefetch=False) for item in coll: item.name self.assertListEqual( handler.hits, ["http://www.boardgamegeek.com/xmlapi/collection/Iago71?own=1"])
def test_collection_prefetch(self): coll = pyBGG.collection("cesco", own=True, prefetch=True) for game in coll: game.names # this would normaly generate a hit hits = [ "http://www.boardgamegeek.com/xmlapi/collection/cesco?own=1", "http://www.boardgamegeek.com/xmlapi/boardgame/66000,68448,31260,43018,2346,58110,2452,34010,60054,24480,19764,8192,20551,40692,57072,57070,71818,27627,34127,20426,11955,28025", ] self.assertListEqual(handler.hits, hits)
def test_prefetch_avoids_fetch(self): coll = pyBGG.collection("cesco", own=True, prefetch=True) pyBGG.boardgame_cache = None # raise exception if hit for bg in coll: self.assertIsInstance(bg.names, list)
def test_prefetch_populates_cache(self): coll = pyBGG.collection("cesco", own=True, prefetch=True) for game in coll: self.assertIn(game.id, pyBGG.boardgame_cache.keys())
def test_collection(self): coll = pyBGG.collection("cesco") self.assertIsInstance(coll, list) self.assertIsInstance(coll[0], pyBGG.BoardGame) self.assertIn(pyBGG.BoardGame.by_id("57070"), coll)
def test_collection_no_prefetch_no_requests(self): coll = pyBGG.collection("Iago71", own=True, prefetch=False) for item in coll: item.name self.assertListEqual(handler.hits, ["http://www.boardgamegeek.com/xmlapi/collection/Iago71?own=1"])
def test_prefetch_populates_cache(self): coll = pyBGG.collection("cesco", own=True, prefetch=True) for game in coll: self.assertIn(game.id, list(pyBGG.boardgame_cache.keys()))