예제 #1
0
def build(match_id, replay_id=None):
  if replay_id is not None:
    session = module.getsession(module.geturl())
    root = os.path.dirname(__file__)
    dirpath = os.path.join(root, 'replay_objs', str(replay_id))
    saver = SaveJsonStream(dirpath)
    for obj in session.gen_replay_objs(replay_id,
      parsed_break=True, uniformize=True):
      saver.send(obj)
    session.close()
예제 #2
0
def test_gen_replay_objs(replay_id):
  root = os.path.dirname(__file__)
  objs_dir = os.path.join(root, 'replay_objs')
  if replay_id is not None:
    replay_ids = [int(replay_id)]
  else:
    replay_ids = sorted(int(x) for x in os.listdir(objs_dir))
  for replay_id in replay_ids:
    print('testing replay ID #{}'.format(replay_id))
    session = module.getsession(module.geturl())
    dirpath = os.path.join(objs_dir, str(replay_id))
    gen = iter_json_stream(dirpath)
    for obj in session.gen_replay_objs(int(replay_id),
        uniformize=True):
      assert obj == next(gen)
    with pytest.raises(StopIteration):
      next(gen)
    session.close()
예제 #3
0
 async def __aenter__(self):
   self.session = ws_command.getsession(loop=self.master.loop)
   await self.session.__aenter__()
   return self