Add a test for the TCPKeepAliveAdapter

Related-Bug: #1430935

Change-Id: Idfea26c8eb6448a4c6adc0f3a916515bd4655c1a
changes/57/163557/3
melanie witt 8 years ago
parent 689a884e18
commit 8c0baaea57
  1. 19
      novaclient/tests/unit/test_client.py

@ -16,6 +16,7 @@
import json
import logging
import socket
import fixtures
import mock
@ -27,6 +28,24 @@ from novaclient.tests.unit import utils
import novaclient.v2.client
class TCPKeepAliveAdapterTest(utils.TestCase):
@mock.patch.object(requests.adapters.HTTPAdapter, 'init_poolmanager')
def test_init_poolmanager(self, mock_init_poolmgr):
adapter = novaclient.client.TCPKeepAliveAdapter()
kwargs = {}
adapter.init_poolmanager(**kwargs)
if requests.__version__ >= '2.4.1':
kwargs.setdefault('socket_options', [
(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),
(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
])
# NOTE(melwitt): This is called twice because
# HTTPAdapter.__init__ calls it first.
self.assertEqual(2, mock_init_poolmgr.call_count)
mock_init_poolmgr.assert_called_with(**kwargs)
class ClientConnectionPoolTest(utils.TestCase):
@mock.patch("novaclient.client.TCPKeepAliveAdapter")

Loading…
Cancel
Save