예제 #1
0
    def test_reliable_link_not_found(self, sleep):
        url = 'test-url'
        fn = Mock(side_effect=_NotFound)

        # test
        wrapped = reliable(fn)
        self.assertRaises(NotFound, wrapped, None)
        self.assertFalse(sleep.called)
예제 #2
0
    def test_reliable_link_not_found(self, sleep):
        url = 'test-url'
        fn = Mock(side_effect=_NotFound)

        # test
        wrapped = reliable(fn)
        self.assertRaises(NotFound, wrapped, None)
        self.assertFalse(sleep.called)
예제 #3
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)
예제 #4
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)
예제 #5
0
    def test_reliable_link_detached(self, sleep):
        url = 'test-url'
        fn = Mock(side_effect=[LinkError, 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),
        ])
예제 #6
0
    def test_reliable_link_detached(self, sleep):
        url = 'test-url'
        fn = Mock(side_effect=[LinkError, 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),
            ])