tests: use requests rather than httplib2
We do not use httplib2 anywhere except there. Requests seems to be largely enough. Change-Id: I9284e6a0609747141791c7f5410cd5a2488b7b34
This commit is contained in:
parent
f06ed91ab8
commit
46f1f09d7c
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#
|
#
|
||||||
# Copyright 2012 eNovance <licensing@enovance.com>
|
# Copyright 2012-2015 eNovance <licensing@enovance.com>
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# not use this file except in compliance with the License. You may obtain
|
# not use this file except in compliance with the License. You may obtain
|
||||||
@ -14,15 +14,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import socket
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import httplib2
|
|
||||||
from oslo_utils import fileutils
|
from oslo_utils import fileutils
|
||||||
|
import requests
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from aodh.tests import base
|
from aodh.tests import base
|
||||||
@ -100,7 +98,6 @@ class BinApiTestCase(base.BaseTestCase):
|
|||||||
|
|
||||||
# create aodh.conf file
|
# create aodh.conf file
|
||||||
self.api_port = random.randint(10000, 11000)
|
self.api_port = random.randint(10000, 11000)
|
||||||
self.http = httplib2.Http(proxy_info=None)
|
|
||||||
self.pipeline_cfg_file = self.path_get('etc/aodh/pipeline.yaml')
|
self.pipeline_cfg_file = self.path_get('etc/aodh/pipeline.yaml')
|
||||||
self.policy_file = self.path_get('etc/aodh/policy.json')
|
self.policy_file = self.path_get('etc/aodh/policy.json')
|
||||||
|
|
||||||
@ -118,13 +115,13 @@ class BinApiTestCase(base.BaseTestCase):
|
|||||||
|
|
||||||
for x in range(10):
|
for x in range(10):
|
||||||
try:
|
try:
|
||||||
r, c = self.http.request(url, 'GET')
|
r = requests.get(url)
|
||||||
except socket.error:
|
except requests.exceptions.ConnectionError:
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
self.assertIsNone(self.subp.poll())
|
self.assertIsNone(self.subp.poll())
|
||||||
else:
|
else:
|
||||||
return r, c
|
return r
|
||||||
return None, None
|
return None
|
||||||
|
|
||||||
def run_api(self, content, err_pipe=None):
|
def run_api(self, content, err_pipe=None):
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
@ -161,11 +158,9 @@ class BinApiTestCase(base.BaseTestCase):
|
|||||||
|
|
||||||
self.subp = self.run_api(content)
|
self.subp = self.run_api(content)
|
||||||
|
|
||||||
response, content = self.get_response('v2/alarms')
|
response = self.get_response('v2/alarms')
|
||||||
self.assertEqual(200, response.status)
|
self.assertEqual(200, response.status_code)
|
||||||
if six.PY3:
|
self.assertEqual([], response.json())
|
||||||
content = content.decode('utf-8')
|
|
||||||
self.assertEqual([], json.loads(content))
|
|
||||||
|
|
||||||
|
|
||||||
class BinEvaluatorTestCase(base.BaseTestCase):
|
class BinEvaluatorTestCase(base.BaseTestCase):
|
||||||
|
@ -8,7 +8,6 @@ Babel>=1.3
|
|||||||
coverage>=3.6
|
coverage>=3.6
|
||||||
fixtures>=1.3.1
|
fixtures>=1.3.1
|
||||||
happybase!=0.7,>=0.5;python_version=='2.7'
|
happybase!=0.7,>=0.5;python_version=='2.7'
|
||||||
httplib2>=0.7.5
|
|
||||||
mock>=1.0
|
mock>=1.0
|
||||||
PyMySQL>=0.6.2 # MIT License
|
PyMySQL>=0.6.2 # MIT License
|
||||||
# Docs Requirements
|
# Docs Requirements
|
||||||
|
Loading…
Reference in New Issue
Block a user