def test_start_hits_transient_error_retry_disabled(self, queue_mock,
                                                       sleep_mock):
        """Ensure if transient error retries are disabled, that those errors are
        re-raised immediately without any attempt to re-insert.
        """
        from google.appengine.api.taskqueue import TransientError
        from furious. async import Async

        queue_mock.return_value.add.side_effect = TransientError()

        async_job = Async("something",
                          queue='my_queue',
                          retry_transient_errors=False)

        self.assertRaises(TransientError, async_job.start)
        self.assertEqual(1, queue_mock.return_value.add.call_count)

        # Try again with the option enabled, this should cause a retry after a
        # delay, which we have also specified.
        queue_mock.reset_mock()
        async_job = Async("something",
                          queue='my_queue',
                          retry_transient_errors=True,
                          retry_delay=12)

        self.assertRaises(TransientError, async_job.start)
        self.assertEqual(2, queue_mock.return_value.add.call_count)
        sleep_mock.assert_called_once_with(12)
    def test_start_hits_transient_error_transactional(self, queue_mock,
                                                      sleep_mock):
        """Ensure if caller is specifying transactional, that Transient errors
        are immediately re-raised.
        """
        from google.appengine.api.taskqueue import TransientError
        from furious. async import Async

        queue_mock.return_value.add.side_effect = TransientError()

        async_job = Async("something",
                          queue='my_queue',
                          retry_transient_errors=True)

        self.assertRaises(TransientError, async_job.start, transactional=True)
        self.assertEqual(1, queue_mock.return_value.add.call_count)
        self.assertEqual(0, sleep_mock.call_count)
Beispiel #3
0
        def add(task, *args, **kwargs):
            def add_second(task, *args, **kwargs):
                assert task

            queue_mock.return_value.add.side_effect = add_second
            raise TransientError()