Merge "Fix and enable integration tests on py35."
This commit is contained in:
commit
085f375a13
@ -249,7 +249,9 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
|
||||
|
||||
def _inject_location_header(self, response, task):
|
||||
location = self._get_task_location(task)
|
||||
response.headers['Location'] = location.encode('utf-8')
|
||||
if six.PY2:
|
||||
location = location.encode('utf-8')
|
||||
response.headers['Location'] = location
|
||||
|
||||
def _get_task_location(self, task):
|
||||
return '/v2/tasks/%s' % task.task_id
|
||||
|
@ -202,7 +202,7 @@ class ApiTest(test_utils.BaseTestCase):
|
||||
|
||||
def _load_paste_app(self, name, flavor, conf):
|
||||
conf_file_path = os.path.join(self.test_dir, '%s-paste.ini' % name)
|
||||
with open(conf_file_path, 'wb') as conf_file:
|
||||
with open(conf_file_path, 'w') as conf_file:
|
||||
conf_file.write(conf)
|
||||
conf_file.flush()
|
||||
return config.load_paste_app(name, flavor=flavor,
|
||||
|
@ -46,7 +46,7 @@ class TestApi(base.ApiTest):
|
||||
|
||||
# 2. POST /images with public image named Image1
|
||||
# attribute and no custom properties. Verify a 200 OK is returned
|
||||
image_data = "*" * FIVE_KB
|
||||
image_data = b"*" * FIVE_KB
|
||||
headers = minimal_headers('Image1')
|
||||
path = "/v1/images"
|
||||
response, content = self.http.request(path, 'POST', headers=headers,
|
||||
@ -100,8 +100,9 @@ class TestApi(base.ApiTest):
|
||||
expected_value,
|
||||
response[expected_key]))
|
||||
|
||||
self.assertEqual("*" * FIVE_KB, content)
|
||||
self.assertEqual(hashlib.md5("*" * FIVE_KB).hexdigest(),
|
||||
content = content.encode('utf-8')
|
||||
self.assertEqual(image_data, content)
|
||||
self.assertEqual(hashlib.md5(image_data).hexdigest(),
|
||||
hashlib.md5(content).hexdigest())
|
||||
|
||||
# 5. GET /images
|
||||
@ -290,7 +291,7 @@ class TestApi(base.ApiTest):
|
||||
self.assertEqual(image_id, response['x-image-meta-id'])
|
||||
|
||||
# 4. PUT image with image data, verify 200 returned
|
||||
image_data = "*" * FIVE_KB
|
||||
image_data = b"*" * FIVE_KB
|
||||
headers = {'Content-Type': 'application/octet-stream'}
|
||||
path = "/v1/images/%s" % (image_id)
|
||||
response, content = self.http.request(path, 'PUT', headers=headers,
|
||||
@ -388,7 +389,7 @@ class TestApi(base.ApiTest):
|
||||
# Content-Type to application/octet-stream, verify a
|
||||
# 400 returned and that the error is readable.
|
||||
with tempfile.NamedTemporaryFile() as test_data_file:
|
||||
test_data_file.write("XXX")
|
||||
test_data_file.write(b"XXX")
|
||||
test_data_file.flush()
|
||||
path = "/v1/images"
|
||||
headers = minimal_headers('Image1')
|
||||
@ -1003,7 +1004,7 @@ class TestApi(base.ApiTest):
|
||||
headers = minimal_headers('Image1')
|
||||
headers['X-Image-Meta-' + format] = 'bad_value'
|
||||
with tempfile.NamedTemporaryFile() as test_data_file:
|
||||
test_data_file.write("XXX")
|
||||
test_data_file.write(b"XXX")
|
||||
test_data_file.flush()
|
||||
response, content = self.http.request(path, 'POST',
|
||||
headers=headers,
|
||||
@ -1054,7 +1055,7 @@ class TestApi(base.ApiTest):
|
||||
headers = minimal_headers('Image1')
|
||||
del headers['X-Image-Meta-' + format]
|
||||
with tempfile.NamedTemporaryFile() as test_data_file:
|
||||
test_data_file.write("XXX")
|
||||
test_data_file.write(b"XXX")
|
||||
test_data_file.flush()
|
||||
response, content = self.http.request(path, 'PUT',
|
||||
headers=headers,
|
||||
|
@ -197,7 +197,7 @@ class ApiTest(test_utils.BaseTestCase):
|
||||
|
||||
def _load_paste_app(self, name, flavor, conf):
|
||||
conf_file_path = os.path.join(self.test_dir, '%s-paste.ini' % name)
|
||||
with open(conf_file_path, 'wb') as conf_file:
|
||||
with open(conf_file_path, 'w') as conf_file:
|
||||
conf_file.write(conf)
|
||||
conf_file.flush()
|
||||
return config.load_paste_app(name, flavor=flavor,
|
||||
|
@ -114,6 +114,8 @@ class TestTasksApi(base.ApiTest):
|
||||
self.assertEqual(task_owner, task['owner'])
|
||||
self.assertEqual(task_data['type'], task['type'])
|
||||
self.assertEqual(task_data['input'], task['input'])
|
||||
self.assertEqual("http://localhost" + path + "/" + task_id,
|
||||
response.webob_resp.headers['Location'])
|
||||
|
||||
return task, task_data
|
||||
|
||||
|
@ -627,9 +627,12 @@ class Httplib2WsgiAdapter(object):
|
||||
|
||||
def request(self, uri, method="GET", body=None, headers=None):
|
||||
req = webob.Request.blank(uri, method=method, headers=headers)
|
||||
req.body = body
|
||||
if isinstance(body, str):
|
||||
req.body = body.encode('utf-8')
|
||||
else:
|
||||
req.body = body
|
||||
resp = req.get_response(self.app)
|
||||
return Httplib2WebobResponse(resp), resp.body
|
||||
return Httplib2WebobResponse(resp), resp.body.decode('utf-8')
|
||||
|
||||
|
||||
class Httplib2WebobResponse(object):
|
||||
|
5
tox.ini
5
tox.ini
@ -64,7 +64,10 @@ commands =
|
||||
glance.tests.functional.v2.test_metadef_resourcetypes \
|
||||
glance.tests.functional.v2.test_metadef_tags \
|
||||
glance.tests.functional.v2.test_images \
|
||||
glance.tests.functional.v2.test_metadef_namespaces
|
||||
glance.tests.functional.v2.test_metadef_namespaces \
|
||||
glance.tests.integration.v2.test_tasks_api \
|
||||
glance.tests.integration.v2.test_property_quota_violations \
|
||||
glance.tests.integration.legacy_functional.test_v1_api
|
||||
|
||||
[testenv:pep8]
|
||||
commands =
|
||||
|
Loading…
Reference in New Issue
Block a user