Merge "Python3: Add support for httplib, urlparse"

This commit is contained in:
Jenkins 2016-04-18 10:02:18 +00:00 committed by Gerrit Code Review
commit b68f3e700f
6 changed files with 20 additions and 20 deletions

View File

@ -19,13 +19,13 @@ Module dedicated functions/classes dealing with rate limiting requests.
import collections
import copy
import httplib
import math
import re
import time
from oslo_serialization import jsonutils
from oslo_utils import importutils
from six.moves import http_client
import webob.dec
import webob.exc
@ -399,7 +399,7 @@ class WsgiLimiterProxy(object):
body = jsonutils.dumps({"verb": verb, "path": path})
headers = {"Content-Type": "application/json"}
conn = httplib.HTTPConnection(self.limiter_address)
conn = http_client.HTTPConnection(self.limiter_address)
if username:
conn.request("POST", "/%s" % (username), body, headers)

View File

@ -12,9 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from six.moves.urllib.parse import unquote
from trove.common import exception
from trove.guestagent.db import models as guest_models
from urllib import unquote
def populate_validated_databases(dbs):

View File

@ -16,9 +16,9 @@ import json
import os
import re
import time
from urlparse import urlparse
from proboscis.asserts import fail
from six.moves.urllib.parse import urlparse
from troveclient.compat.client import TroveHTTPClient
from trove.tests.config import CONFIG

View File

@ -15,7 +15,6 @@
from hashlib import md5
from mock import MagicMock, patch
import httplib
import json
import os
import socket
@ -24,6 +23,7 @@ import swiftclient.client as swift_client
import uuid
from oslo_log import log as logging
from six.moves import http_client
from swiftclient import client as swift
from trove.common.i18n import _ # noqa
@ -77,10 +77,10 @@ class FakeSwiftConnection(object):
LOG.debug("fake head_container(%s)" % container)
if container == 'missing_container':
raise swift.ClientException('fake exception',
http_status=httplib.NOT_FOUND)
http_status=http_client.NOT_FOUND)
elif container == 'unauthorized_container':
raise swift.ClientException('fake exception',
http_status=httplib.UNAUTHORIZED)
http_status=http_client.UNAUTHORIZED)
elif container == 'socket_error_on_head':
raise socket.error(111, 'ECONNREFUSED')
pass

View File

@ -17,12 +17,11 @@
Tests dealing with HTTP rate-limiting.
"""
import httplib
from mock import Mock, MagicMock, patch
from oslo_serialization import jsonutils
import six
from six.moves import http_client
import webob
from trove.common import limits
@ -557,7 +556,7 @@ class WsgiLimiterTest(BaseLimitTestSuite):
class FakeHttplibSocket(object):
"""
Fake `httplib.HTTPResponse` replacement.
Fake `http_client.HTTPResponse` replacement.
"""
def __init__(self, response_string):
@ -571,7 +570,7 @@ class FakeHttplibSocket(object):
class FakeHttplibConnection(object):
"""
Fake `httplib.HTTPConnection`.
Fake `http_client.HTTPConnection`.
"""
def __init__(self, app, host):
@ -585,7 +584,7 @@ class FakeHttplibConnection(object):
"""
Requests made via this connection actually get translated and routed
into our WSGI app, we then wait for the response and turn it back into
an `httplib.HTTPResponse`.
an `http_client.HTTPResponse`.
"""
if not headers:
headers = {}
@ -599,7 +598,7 @@ class FakeHttplibConnection(object):
resp = str(req.get_response(self.app))
resp = "HTTP/1.0 %s" % resp
sock = FakeHttplibSocket(resp)
self.http_response = httplib.HTTPResponse(sock)
self.http_response = http_client.HTTPResponse(sock)
self.http_response.begin()
def getresponse(self):
@ -613,7 +612,7 @@ def wire_HTTPConnection_to_WSGI(host, app):
After calling this method, when any code calls
httplib.HTTPConnection(host)
http_client.HTTPConnection(host)
the connection object will be a fake. Its requests will be sent directly
to the given WSGI app rather than through a socket.
@ -641,8 +640,9 @@ def wire_HTTPConnection_to_WSGI(host, app):
else:
return self.wrapped(connection_host, *args, **kwargs)
oldHTTPConnection = httplib.HTTPConnection
httplib.HTTPConnection = HTTPConnectionDecorator(httplib.HTTPConnection)
oldHTTPConnection = http_client.HTTPConnection
http_client.HTTPConnection = HTTPConnectionDecorator(
http_client.HTTPConnection)
return oldHTTPConnection
@ -654,7 +654,7 @@ class WsgiLimiterProxyTest(BaseLimitTestSuite):
def setUp(self):
"""
Do some nifty HTTP/WSGI magic which allows for WSGI to be called
directly by something like the `httplib` library.
directly by something like the `http_client` library.
"""
super(WsgiLimiterProxyTest, self).setUp()
self.app = limits.WsgiLimiter(TEST_LIMITS)
@ -681,7 +681,7 @@ class WsgiLimiterProxyTest(BaseLimitTestSuite):
def tearDown(self):
# restore original HTTPConnection object
httplib.HTTPConnection = self.oldHTTPConnection
http_client.HTTPConnection = self.oldHTTPConnection
super(WsgiLimiterProxyTest, self).tearDown()

View File

@ -23,8 +23,6 @@
"""
import subprocess
from urllib import unquote
try:
EVENT_AVAILABLE = True
except ImportError:
@ -34,6 +32,7 @@ from proboscis.asserts import assert_true
from proboscis.asserts import Check
from proboscis.asserts import fail
from proboscis import SkipTest
from six.moves.urllib.parse import unquote
from sqlalchemy import create_engine
from troveclient.compat import Dbaas
from troveclient.compat import exceptions