def testAcquireWithNoCallbackStillWorksWithNoTimeout(self):
     tm = CallbackSynchroniser()
     tId = tm.create()
     t = threading.Timer(1, self._releaseResult, args=[tm, tId, self.eResult])
     self._timers.append(t)
     t.start()
     result = tm.acquireNew(tId)
     assert result == self.eResult, "Unexpected result received: %(R)s, expecting: %(E)s" % {"R":result, "E":self.eResult}
 def testAcquireWithNoCallbackStillWorksWithTimeout(self):
     self.theResult = None
     tm = CallbackSynchroniser()
     tId = tm.create()
     try:
         tm.acquireNew(tId, timeout=1)
     except TransactionFailed, _e:
         assert True
 def testResultCallsCallback(self):
     self.cbCalled = False
     self.theResult = None
     self.cbI = None
     def cb(i, result=None):
         self.cbI = i
         self.cbCalled = True
         self.theResult = result
     tm = CallbackSynchroniser()
     tId = tm.create(callback=cb)
     tm.release(tId, self.eResult)
     assert self.cbCalled == True, "cb not called!"
     assert self.theResult == self.eResult, "unexpected result: %(T)s" % {"T":self._theResult}
 def testAcquireWithCallbackRaisesTypeError(self):
     self.cbCalled = False
     self.theResult = None
     self.cbI = None
     def cb(i, result=None):
         self.cbI = i
         self.cbCalled = True
         self.theResult = result
     tm = CallbackSynchroniser()
     tId = tm.create(callback=cb)
     try:
         tm.acquireNew(tId)
     except TypeError, _e:
         assert True