def test_resend_exhausted(self, sleep, delivery): url = 'test-url' delivery.RELEASED = 1 fn = Mock(side_effect=SendException(delivery.RELEASED)) messenger = Mock(url=url, connection=Mock()) args = (messenger, 2, 3) kwargs = {'A': 1} # test wrapped = resend(fn) wrapped(*args, **kwargs) # validation self.assertEqual( sleep.call_args_list, [ ((RESEND_DELAY,), {}), ((RESEND_DELAY,), {}), ((RESEND_DELAY,), {}), ((RESEND_DELAY,), {}), ]) self.assertEqual( fn.call_args_list, [ (args, kwargs), (args, kwargs), (args, kwargs), (args, kwargs), ])
def test_resend_exhausted(self, sleep, delivery): url = 'test-url' delivery.RELEASED = 1 fn = Mock(side_effect=SendException(delivery.RELEASED)) messenger = Mock(url=url, connection=Mock()) args = (messenger, 2, 3) kwargs = {'A': 1} # test wrapped = resend(fn) wrapped(*args, **kwargs) # validation self.assertEqual(sleep.call_args_list, [ ((RESEND_DELAY, ), {}), ((RESEND_DELAY, ), {}), ((RESEND_DELAY, ), {}), ((RESEND_DELAY, ), {}), ]) self.assertEqual(fn.call_args_list, [ (args, kwargs), (args, kwargs), (args, kwargs), (args, kwargs), ])
def test_resend_rejected(self, sleep, delivery): url = 'test-url' delivery.RELEASED = 1 delivery.REJECTED = 2 fn = Mock(side_effect=[SendException(delivery.REJECTED), None]) messenger = Mock(url=url, connection=Mock()) args = (messenger, 2, 3) kwargs = {'A': 1} # test wrapped = resend(fn) self.assertRaises(SendException, wrapped, *args, **kwargs) self.assertFalse(sleep.called)
def test_resend_released(self, sleep, delivery): url = 'test-url' delivery.RELEASED = 1 fn = Mock(side_effect=[SendException(delivery.RELEASED), None]) messenger = Mock(url=url, connection=Mock()) args = (messenger, 2, 3) kwargs = {'A': 1} # test wrapped = resend(fn) wrapped(*args, **kwargs) # validation sleep.assert_called_once_with(RESEND_DELAY) self.assertEqual(fn.call_args_list, [ (args, kwargs), (args, kwargs), ])
def test_resend_released(self, sleep, delivery): url = 'test-url' delivery.RELEASED = 1 fn = Mock(side_effect=[SendException(delivery.RELEASED), None]) messenger = Mock(url=url, connection=Mock()) args = (messenger, 2, 3) kwargs = {'A': 1} # test wrapped = resend(fn) wrapped(*args, **kwargs) # validation sleep.assert_called_once_with(RESEND_DELAY) self.assertEqual( fn.call_args_list, [ (args, kwargs), (args, kwargs), ])