Пример #1
0
 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"])
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
 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())
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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"])
Пример #9
0
 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()))
Пример #10
0
 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)