def test_send_request(self):
        bt = BaseThrottler()

        throttled_request, _ = bt._prepare_request(self.default_request)
        bt._send_request(throttled_request)
      
        self.assertEqual(1, bt.successes)
        self.assertEqual(0, bt.failures)
        self.assertTrue(throttled_request.finished)
        self.assertIsNotNone(throttled_request._response)
        self.assertIsNone(throttled_request._exception)

        bt = BaseThrottler()

        request = requests.Request(method=None, url='http://None')
        throttled_request, _ = bt._prepare_request(request)
        bt._send_request(throttled_request)
      
        self.assertEqual(1, bt.failures)
        self.assertEqual(0, bt.successes)
        self.assertTrue(throttled_request.finished)
        self.assertIsNone(throttled_request._response)
        self.assertIsNotNone(throttled_request._exception)
        self.assertIsInstance(throttled_request._exception, Exception)

        with self.assertRaises(Exception):
            throttled_request.response
示例#2
0
    def test_send_request(self):
        bt = BaseThrottler()

        throttled_request, _ = bt._prepare_request(self.default_request)
        bt._send_request(throttled_request)

        self.assertEqual(1, bt.successes)
        self.assertEqual(0, bt.failures)
        self.assertTrue(throttled_request.finished)
        self.assertIsNotNone(throttled_request._response)
        self.assertIsNone(throttled_request._exception)

        bt = BaseThrottler()

        request = requests.Request(method=None, url='http://None')
        throttled_request, _ = bt._prepare_request(request)
        bt._send_request(throttled_request)

        self.assertEqual(1, bt.failures)
        self.assertEqual(0, bt.successes)
        self.assertTrue(throttled_request.finished)
        self.assertIsNone(throttled_request._response)
        self.assertIsNotNone(throttled_request._exception)
        self.assertIsInstance(throttled_request._exception, Exception)

        with self.assertRaises(Exception):
            throttled_request.response
    def test_send_request(self):
        bt = BaseThrottler()

        throttled_request, _ = bt._prepare_request(self.default_request)
        bt._send_request(throttled_request)

        self.assertEqual(1, bt.successes)
        self.assertEqual(0, bt.failures)
        self.assertTrue(throttled_request.finished)
        self.assertIsNotNone(throttled_request._response)
        self.assertIsNone(throttled_request._exception)
    def test_send_request(self):
        bt = BaseThrottler()

        throttled_request, _ = bt._prepare_request(self.default_request)
        bt._send_request(throttled_request)

        self.assertEqual(1, bt.successes)
        self.assertEqual(0, bt.failures)
        self.assertTrue(throttled_request.finished)
        self.assertIsNotNone(throttled_request._response)
        self.assertIsNone(throttled_request._exception)