Ejemplo n.º 1
0
 def testPortalRulebooksCache(self):
     portrb = StructuredDefaultDict(1, dict)
     for (character, nodeA, nodeB,
          rulebook) in self.engine.query.portals_rulebooks():
         portrb[character][nodeA][nodeB] = rulebook
     self.assertDictEqual(portrb,
                          self.engine._portals_rulebooks_cache._data)
Ejemplo n.º 2
0
 def testAvatarnessCaches(self):
     user_avatarness = StructuredDefaultDict(3, WindowDict)
     for (character, graph, node, branch, tick,
          is_avatar) in self.engine.query.avatarness_dump():
         user_avatarness[graph][node][character][branch][tick] = is_avatar
     new_user_avatarness = StructuredDefaultDict(3, WindowDict)
     usr = self.engine._avatarness_cache.user_order
     for graph in usr:
         for node in usr[graph]:
             for char in usr[graph][node]:
                 if usr[graph][node][char]:
                     for branch in usr[graph][node][char]:
                         for tick, is_avatar in usr[graph][node][char][
                                 branch].items():
                             new_user_avatarness[graph][node][char][branch][
                                 tick] = is_avatar
     self.assertDictEqual(user_avatarness, new_user_avatarness)
Ejemplo n.º 3
0
 def __init__(self, engine):
     Cache.__init__(self, engine)
     self.user_order = StructuredDefaultDict(3, TurnDict)
     self.user_shallow = PickyDefaultDict(TurnDict)
     self.graphs = StructuredDefaultDict(1, TurnDict)
     self.graphavs = StructuredDefaultDict(1, TurnDict)
     self.charavs = StructuredDefaultDict(1, TurnDict)
     self.soloav = StructuredDefaultDict(1, TurnDict)
     self.uniqav = StructuredDefaultDict(1, TurnDict)
     self.uniqgraph = StructuredDefaultDict(1, TurnDict)
     self.users = StructuredDefaultDict(1, TurnDict)
Ejemplo n.º 4
0
 def testCharRulesHandledCaches(self):
     live = self.engine._character_rules_handled_cache._data
     for rulemap in [
             'character', 'avatar', 'character_thing', 'character_place',
             'character_portal'
     ]:
         handled_ticks = StructuredDefaultDict(2, set)
         for character, rulebook, rule, branch, tick in getattr(
                 self.engine.query, 'handled_{}_rules'.format(rulemap))():
             handled_ticks[character][rule][branch].add(tick)
         old_handled_ticks = StructuredDefaultDict(2, set)
         for character in live:
             if live[character][rulemap]:
                 for rule in live[character][rulemap]:
                     for branch, ticks in live[character][rulemap][
                             rule].items():
                         self.assertIsInstance(ticks, set)
                         old_handled_ticks[character][rule][branch] = ticks
         self.assertDictEqual(old_handled_ticks, handled_ticks,
                              "\n{} cache differs from DB".format(rulemap))
Ejemplo n.º 5
0
 def __init__(self, engine):
     self.engine = engine
     self._data = StructuredDefaultDict(3, set)
     self.shallow = {}
     self.unhandled = StructuredDefaultDict(2, dict)
Ejemplo n.º 6
0
 def __init__(self, engine):
     Cache.__init__(self, engine)
     self.active_sets = StructuredDefaultDict(1, FuturistWindowDict)
Ejemplo n.º 7
0
 def testThingsCache(self):
     things = StructuredDefaultDict(3, tuple)
     for (character, thing, branch, tick, loc, nextloc) in \
             self.engine.query.things_dump():
         things[(character, )][thing][branch][tick] = (loc, nextloc)
     self.assertDictEqual(things, self.engine._things_cache.keys)