Ejemplo n.º 1
0
 def test_lock_already_acquired(self):
     """
     If lock is already acquired, it will just call eff
     """
     self.lb.acquired = True
     seq = [("call", const("eff_return"))]
     self.assertEqual(
         perform_sequence(seq, zk.call_if_acquired(self.lock,
                                                   Effect("call"))),
         ("eff_return", False))
Ejemplo n.º 2
0
 def test_lock_already_acquired(self):
     """
     If lock is already acquired, it will just call eff
     """
     self.lb.acquired = True
     seq = [("call", const("eff_return"))]
     self.assertEqual(
         perform_sequence(
             seq,
             zk.call_if_acquired(self.lock, Effect("call"))),
         ("eff_return", False))
Ejemplo n.º 3
0
 def test_lock_acquired(self):
     """
     When lock is not acquired, it is tried and if successful calls eff
     """
     self.lb.acquired = False
     self.lb.acquire_call = (False, None, True)
     seq = [("call", const("eff_return"))]
     self.assertEqual(
         perform_sequence(seq, zk.call_if_acquired(self.lock,
                                                   Effect("call"))),
         ("eff_return", True))
Ejemplo n.º 4
0
 def test_lock_not_acquired(self):
     """
     When lock is not acquired, it is tried and if failed does not
     call eff
     """
     self.lb.acquired = False
     self.lb.acquire_call = (False, None, False)
     self.assertEqual(
         sync_perform(base_dispatcher,
                      zk.call_if_acquired(self.lock, Effect("call"))),
         (zk.NOT_CALLED, False))
Ejemplo n.º 5
0
 def test_lock_acquired(self):
     """
     When lock is not acquired, it is tried and if successful calls eff
     """
     self.lb.acquired = False
     self.lb.acquire_call = (False, None, True)
     seq = [("call", const("eff_return"))]
     self.assertEqual(
         perform_sequence(
             seq,
             zk.call_if_acquired(self.lock, Effect("call"))),
         ("eff_return", True))
Ejemplo n.º 6
0
 def test_lock_not_acquired(self):
     """
     When lock is not acquired, it is tried and if failed does not
     call eff
     """
     self.lb.acquired = False
     self.lb.acquire_call = (False, None, False)
     self.assertEqual(
         sync_perform(
             base_dispatcher,
             zk.call_if_acquired(self.lock, Effect("call"))),
         (zk.NOT_CALLED, False))