예제 #1
0
 def test_correct_get_socket(self):
     mock_socket = mock.Mock()
     self.useFixture(fixtures.MonkeyPatch("glance.common.wsgi.ssl.wrap_socket", mock_socket))
     self.useFixture(fixtures.MonkeyPatch("glance.common.wsgi.eventlet.listen", lambda *x, **y: None))
     wsgi.get_socket(1234)
     self.assertIn(mock.call().setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1), mock_socket.mock_calls)
     self.assertIn(mock.call().setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1), mock_socket.mock_calls)
     if hasattr(socket, "TCP_KEEPIDLE"):
         self.assertIn(
             mock.call().setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, wsgi.CONF.tcp_keepidle),
             mock_socket.mock_calls,
         )
예제 #2
0
파일: test_wsgi.py 프로젝트: zaina/glance
 def test_correct_get_socket(self):
     mock_socket = mock.Mock()
     self.useFixture(
         fixtures.MonkeyPatch('glance.common.wsgi.ssl.wrap_socket',
                              mock_socket))
     self.useFixture(
         fixtures.MonkeyPatch('glance.common.wsgi.eventlet.listen',
                              lambda *x, **y: None))
     wsgi.get_socket(1234)
     self.assertTrue(
         mock.call().setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,
                                1) in mock_socket.mock_calls)
     self.assertTrue(
         mock.call().setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE,
                                1) in mock_socket.mock_calls)
     if hasattr(socket, 'TCP_KEEPIDLE'):
         self.assertTrue(mock.call().setsockopt(
             socket.IPPROTO_TCP, socket.TCP_KEEPIDLE,
             wsgi.CONF.tcp_keepidle) in mock_socket.mock_calls)