Exemplo n.º 1
0
 def _LocallyWhitelistForAllVoters(self):
   upvoter_keys = self._GetUpvoters()
   logging.info(
       'Locally whitelisting %s for all voters: %s', self.blockable.key.id(),
       sorted(key.id() for key in upvoter_keys))
   return model_utils.GetChainingMultiFuture(
       self._LocallyWhitelistForVoter(key) for key in upvoter_keys)
Exemplo n.º 2
0
  def testSingleFuture(self):
    f = ndb.Future()
    mf = utils.GetChainingMultiFuture([f])

    self.assertFalse(f.done())
    self.assertFalse(mf.done())

    f.set_result([])

    self.assertTrue(f.done())
    self.assertFalse(mf.done())

    # Event loop must run for the MultiFuture to be marked as done.
    mf.wait()

    self.assertTrue(mf.done())
    self.assertEqual([], mf.get_result())
Exemplo n.º 3
0
  def testManyFutures(self):
    futures = [ndb.Future() for _ in xrange(3)]
    mf = utils.GetChainingMultiFuture(futures)

    self.assertFalse(any(f.done() for f in futures))
    self.assertFalse(mf.done())

    for i, f in enumerate(futures):
      f.set_result([i])

    self.assertTrue(all(f.done() for f in futures))
    self.assertFalse(mf.done())

    # Event loop must run for the MultiFuture to be marked as done.
    mf.wait()

    self.assertTrue(mf.done())
    self.assertEqual([0, 1, 2], mf.get_result())
Exemplo n.º 4
0
 def testCantModifyResult(self):
   f = ndb.Future()
   mf = utils.GetChainingMultiFuture([f])
   with self.assertRaises(RuntimeError):
     mf.add_dependent(ndb.Future())
Exemplo n.º 5
0
 def testNoInput(self):
   mf = utils.GetChainingMultiFuture([])
   self.assertTrue(mf.done())