示例#1
0
 def test_cancel_already_done(self):
     """
     If the lookup is already done, ensure a call to cancel returns the
     expected (False) result.
     """
     lookup = Lookup(FindNode, self.target, self.node, self.event_loop)
     lookup.set_result('foo')
     result = lookup.cancel()
     self.assertFalse(result)
示例#2
0
 def test_cancel_already_done(self):
     """
     If the lookup is already done, ensure a call to cancel returns the
     expected (False) result.
     """
     lookup = Lookup(FindNode, self.target, self.node, self.event_loop)
     lookup.set_result('foo')
     result = lookup.cancel()
     self.assertFalse(result)
示例#3
0
 def test_cancel(self):
     """
     Ensure that the expected operations happen when the lookup's cancel
     method is called (the pending requests also need to be cancelled).
     """
     patcher = mock.patch('asyncio.Future.cancel')
     mock_cancel = patcher.start()
     lookup = Lookup(FindNode, self.target, self.node, self.event_loop)
     lookup._cancel_pending_requests = mock.MagicMock()
     result = lookup.cancel()
     self.assertTrue(result)
     self.assertEqual(lookup._cancel_pending_requests.call_count, 1)
     self.assertEqual(mock_cancel.call_count, 1)
     patcher.stop()
示例#4
0
 def test_cancel(self):
     """
     Ensure that the expected operations happen when the lookup's cancel
     method is called (the pending requests also need to be cancelled).
     """
     patcher = mock.patch('asyncio.Future.cancel')
     mock_cancel = patcher.start()
     lookup = Lookup(FindNode, self.target, self.node, self.event_loop)
     lookup._cancel_pending_requests = mock.MagicMock()
     result = lookup.cancel()
     self.assertTrue(result)
     self.assertEqual(lookup._cancel_pending_requests.call_count, 1)
     self.assertEqual(mock_cancel.call_count, 1)
     patcher.stop()