'Each requested connection must be closed by calling \'remove_connection\'
when the server doesn\'t support persistent HTTP Connections'

def test_get_and_remove_conn(self):

    kah = self.kahdler
    host = self.host
    conn = self.conn
    req = self.req
    req.get_host = MagicMock(return_value=host)
    req.get_full_url = MagicMock(return_value='test_full_url')
    kah._start_transaction = MagicMock(return_value=None)
    conn_factory = kah.get_connection
    resp = HTTPResponse(socket.socket())
    resp.will_close = True
    resp.read = MagicMock(return_value='Response    body')
    conn.getresponse = MagicMock(return_value=resp)
    conn_mgr_mock = Mock()
    conn_mgr_mock.get_available_connection = MagicMock(return_value=conn)
    conn_mgr_mock.remove_connection = MagicMock(return_value=None)
    kah._cm = conn_mgr_mock
    kah.do_open(req)
    kah._start_transaction.assert_called_once_with(conn, req)
    conn_mgr_mock.get_available_connection.assert_called_once_with(req, conn_factory)
    conn_mgr_mock.remove_connection.assert_called_once_with(conn, host, reason='will    close')
