コード例 #1
0
    def test_exception(self):
        """test_asyncclient | exception retries
        """
        session = getExceptionSession()
        client = newClient(session=session)

        with mock.patch.object(utils, 'calculateSleepTime') as p:
            p.return_value = .001
            with self.assertRaises(exceptions.TaskclusterConnectionError):
                asyncio.get_event_loop().run_until_complete(
                    client._makeHttpRequest('get', 'http://example.com',
                                            '{"clientScopes": ["a"]}',
                                            {}, session=session)
                )
コード例 #2
0
    def _too_many_exception_retries(self, exception=aiohttp.ClientError,
                                    expectedRetries=utils.MAX_RETRIES + 1):
        """helper method to hit all the try/excepts in asyncutils.makeHttpRequest
        """
        session = getExceptionSession(exception=exception)

        with mock.patch.object(utils, 'calculateSleepTime') as p:
            p.return_value = .001
            with self.assertRaises(exception):
                asyncio.get_event_loop().run_until_complete(
                    asyncutils.makeHttpRequest('get', 'http://example.com',
                                               '{"clientScopes": ["a"]}',
                                               {}, session=session)
                )

        self.assertEqual(expectedRetries, session.count)