Esempio n. 1
0
    def test_reliable(self):
        fn = Mock()
        messenger = Mock()
        args = (messenger, 2, 3)
        kwargs = {'A': 1}

        # test
        wrapped = reliable(fn)
        wrapped(*args, **kwargs)

        # validation
        fn.assert_called_once_with(*args, **kwargs)
Esempio n. 2
0
    def test_reliable(self):
        fn = Mock()
        messenger = Mock()
        args = (messenger, 2, 3)
        kwargs = {'A': 1}

        # test
        wrapped = reliable(fn)
        wrapped(*args, **kwargs)

        # validation
        fn.assert_called_once_with(*args, **kwargs)
Esempio n. 3
0
    def test_reliable_channel_exception_not_found(self, sleep):
        url = 'test-url'
        fn = Mock(side_effect=[ChannelError(404), None])
        messenger = Mock(url=url, connection=Mock())
        args = (messenger, 2, 3)
        kwargs = {'A': 1}

        # test
        wrapped = reliable(fn)

        # validation
        self.assertRaises(NotFound, wrapped, *args, **kwargs)
        self.assertFalse(sleep.called)
Esempio n. 4
0
    def test_reliable_channel_exception_no_route(self, sleep):
        url = 'test-url'
        fn = Mock(side_effect=[ChannelError(312), None])
        messenger = Mock(url=url, connection=Mock())
        args = (messenger, 2, 3)
        kwargs = {'A': 1}

        # test
        wrapped = reliable(fn)

        # validation
        self.assertRaises(NotFound, wrapped, *args, **kwargs)
        self.assertFalse(sleep.called)
Esempio n. 5
0
    def test_reliable_channel_exception(self, sleep):
        url = 'test-url'
        fn = Mock(side_effect=[ChannelError, None])
        messenger = Mock(url=url, connection=Mock())
        args = (messenger, 2, 3)
        kwargs = {'A': 1}

        # test
        wrapped = reliable(fn)
        wrapped(*args, **kwargs)

        # validation
        sleep.assert_called_once_with(DELAY)
        messenger.repair.assert_called_once_with()
        self.assertEqual(fn.call_args_list, [
            (args, kwargs),
            (args, kwargs),
        ])
Esempio n. 6
0
    def test_reliable_channel_exception(self, sleep):
        url = 'test-url'
        fn = Mock(side_effect=[ChannelError, None])
        messenger = Mock(url=url, connection=Mock())
        args = (messenger, 2, 3)
        kwargs = {'A': 1}

        # test
        wrapped = reliable(fn)
        wrapped(*args, **kwargs)

        # validation
        sleep.assert_called_once_with(DELAY)
        messenger.repair.assert_called_once_with()
        self.assertEqual(
            fn.call_args_list,
            [
                (args, kwargs),
                (args, kwargs),
            ])
Esempio n. 7
0
def reliable(fn):
    return reliability.endpoint(reliability.reliable(fn))
Esempio n. 8
0
def reliable(fn):
    return reliability.endpoint(reliability.reliable(fn))