Port to python3.4
This commit is contained in:
parent
9d15aa980e
commit
2723df20d4
|
@ -11,11 +11,12 @@
|
|||
# limitations under the License.
|
||||
|
||||
import base64
|
||||
import httplib
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
|
||||
from six.moves import http_client
|
||||
|
||||
from openstack_qa_tools import error
|
||||
|
||||
DSTAT_RABBITMQ_API = os.environ.get('DSTAT_RABBITMQ_API',
|
||||
|
@ -27,15 +28,15 @@ DSTAT_RABBITMQ_API_PASS = os.environ.get('DSTAT_RABBITMQ_PASS',
|
|||
|
||||
|
||||
def collect():
|
||||
conn = httplib.HTTPConnection(DSTAT_RABBITMQ_API)
|
||||
auth = base64.encodestring('%s:%s' % (DSTAT_RABBITMQ_API_USER,
|
||||
DSTAT_RABBITMQ_API_PASS))
|
||||
conn = http_client.HTTPConnection(DSTAT_RABBITMQ_API)
|
||||
auth = '%s:%s' % (DSTAT_RABBITMQ_API_USER, DSTAT_RABBITMQ_API_PASS)
|
||||
auth = base64.encodestring(auth.encode('utf-8')).decode('ascii')
|
||||
auth = auth.replace('\n', '')
|
||||
auth = {'Authorization': 'Basic %s' % auth}
|
||||
try:
|
||||
conn.request('GET', '/api/queues', headers=auth)
|
||||
content = conn.getresponse().read()
|
||||
except (socket.error, httplib.HTTPException) as e:
|
||||
except (socket.error, http_client.HTTPException) as e:
|
||||
raise error.CollectionError(str(e))
|
||||
|
||||
content = json.loads(content)
|
||||
|
|
|
@ -27,9 +27,9 @@ from openstack_qa_tools.tests import base
|
|||
|
||||
class TestOpenStackQaTols(base.TestCase):
|
||||
|
||||
@mock.patch('httplib.HTTPConnection')
|
||||
@mock.patch('six.moves.http_client.HTTPConnection')
|
||||
def test_queues(self, httplib_mock):
|
||||
reader = mock.MagicMock()
|
||||
reader = mock.MagicMock(name='getresponse_reader')
|
||||
reader.read.return_value = '[]'
|
||||
conn = httplib_mock.return_value
|
||||
conn.getresponse.return_value = reader
|
||||
|
|
Loading…
Reference in New Issue