Merge "Port API v1 and v2 to Python 3"
This commit is contained in:
commit
ab7ea8aae9
@ -409,7 +409,7 @@ class JSONDictSerializer(DictSerializer):
|
||||
"""Default JSON request body serialization."""
|
||||
|
||||
def default(self, data):
|
||||
return jsonutils.dumps(data)
|
||||
return jsonutils.dump_as_bytes(data)
|
||||
|
||||
|
||||
class XMLDictSerializer(DictSerializer):
|
||||
|
@ -436,7 +436,7 @@ class WsgiLimiterProxy(object):
|
||||
self.limiter_address = limiter_address
|
||||
|
||||
def check_for_delay(self, verb, path, username=None):
|
||||
body = jsonutils.dumps({"verb": verb, "path": path})
|
||||
body = jsonutils.dump_as_bytes({"verb": verb, "path": path})
|
||||
headers = {"Content-Type": "application/json"}
|
||||
|
||||
conn = http_client.HTTPConnection(self.limiter_address)
|
||||
|
@ -433,7 +433,7 @@ class WsgiLimiterProxy(object):
|
||||
self.limiter_address = limiter_address
|
||||
|
||||
def check_for_delay(self, verb, path, username=None):
|
||||
body = jsonutils.dumps({"verb": verb, "path": path})
|
||||
body = jsonutils.dump_as_bytes({"verb": verb, "path": path})
|
||||
headers = {"Content-Type": "application/json"}
|
||||
|
||||
conn = http_client.HTTPConnection(self.limiter_address)
|
||||
|
@ -16,6 +16,7 @@
|
||||
"""The volumes snapshots api."""
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import strutils
|
||||
import webob
|
||||
from webob import exc
|
||||
@ -177,7 +178,8 @@ class SnapshotsController(wsgi.Controller):
|
||||
try:
|
||||
force = strutils.bool_from_string(force, strict=True)
|
||||
except ValueError as error:
|
||||
msg = _("Invalid value for 'force': '%s'") % error.message
|
||||
err_msg = encodeutils.exception_to_unicode(error)
|
||||
msg = _("Invalid value for 'force': '%s'") % err_msg
|
||||
raise exception.InvalidParameterValue(err=msg)
|
||||
|
||||
if force:
|
||||
|
@ -216,10 +216,10 @@ class XMLDictSerializerTest(test.TestCase):
|
||||
class JSONDictSerializerTest(test.TestCase):
|
||||
def test_json(self):
|
||||
input_dict = dict(servers=dict(a=(2, 3)))
|
||||
expected_json = '{"servers":{"a":[2,3]}}'
|
||||
expected_json = b'{"servers":{"a":[2,3]}}'
|
||||
serializer = wsgi.JSONDictSerializer()
|
||||
result = serializer.serialize(input_dict)
|
||||
result = result.replace('\n', '').replace(' ', '')
|
||||
result = result.replace(b'\n', b'').replace(b' ', b'')
|
||||
self.assertEqual(expected_json, result)
|
||||
|
||||
|
||||
|
@ -569,7 +569,7 @@ class WsgiLimiterTest(BaseLimitTestSuite):
|
||||
|
||||
def _request_data(self, verb, path):
|
||||
"""Get data describing a limit request verb/path."""
|
||||
return jsonutils.dumps({"verb": verb, "path": path})
|
||||
return jsonutils.dump_as_bytes({"verb": verb, "path": path})
|
||||
|
||||
def _request(self, verb, url, username=None):
|
||||
"""Assert that POSTing to given url triggers given action.
|
||||
@ -636,9 +636,11 @@ class FakeHttplibSocket(object):
|
||||
|
||||
def __init__(self, response_string):
|
||||
"""Initialize new `FakeHttplibSocket`."""
|
||||
self._buffer = six.StringIO(response_string)
|
||||
if isinstance(response_string, six.text_type):
|
||||
response_string = response_string.encode('utf-8')
|
||||
self._buffer = six.BytesIO(response_string)
|
||||
|
||||
def makefile(self, _mode, _other):
|
||||
def makefile(self, mode, *args):
|
||||
"""Returns the socket's internal buffer."""
|
||||
return self._buffer
|
||||
|
||||
@ -754,8 +756,9 @@ class WsgiLimiterProxyTest(BaseLimitTestSuite):
|
||||
delay, error = self.proxy.check_for_delay("GET", "/delayed")
|
||||
error = error.strip()
|
||||
|
||||
expected = ("60.00", "403 Forbidden\n\nOnly 1 GET request(s) can be "
|
||||
"made to /delayed every minute.")
|
||||
expected = ("60.00",
|
||||
b"403 Forbidden\n\nOnly 1 GET request(s) can be "
|
||||
b"made to /delayed every minute.")
|
||||
|
||||
self.assertEqual(expected, (delay, error))
|
||||
|
||||
@ -827,7 +830,7 @@ class LimitsXMLSerializationTest(test.TestCase):
|
||||
"absolute": {}}}
|
||||
|
||||
output = serializer.serialize(fixture)
|
||||
has_dec = output.startswith("<?xml version='1.0' encoding='UTF-8'?>")
|
||||
has_dec = output.startswith(b"<?xml version='1.0' encoding='UTF-8'?>")
|
||||
self.assertTrue(has_dec)
|
||||
|
||||
def test_index(self):
|
||||
|
@ -292,7 +292,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
body = {"metadata": {"key1": "value1",
|
||||
"key2": "value2",
|
||||
"key3": "value3"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
res_dict = self.controller.create(req, self.req_id, body)
|
||||
self.assertEqual(body, res_dict)
|
||||
|
||||
@ -326,7 +326,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
"key2": "value2",
|
||||
"key3": "value3",
|
||||
"KEY4": "value4"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
res_dict = self.controller.create(req, self.req_id, body)
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
@ -346,7 +346,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -358,7 +358,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {("a" * 260): "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -375,7 +375,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.content_type = "application/json"
|
||||
body = {"metadata": {"key9": "value9"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.create, req, self.req_id, body)
|
||||
|
||||
@ -402,7 +402,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'KEY20': 'value20',
|
||||
},
|
||||
}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
res_dict = self.controller.update_all(req, self.req_id, expected)
|
||||
|
||||
self.assertEqual(expected, res_dict)
|
||||
@ -442,7 +442,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'KEY20': 'value20',
|
||||
},
|
||||
}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
res_dict = self.controller.update_all(req, self.req_id, body)
|
||||
|
||||
self.assertEqual(expected, res_dict)
|
||||
@ -465,7 +465,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'metadata': {}}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
res_dict = self.controller.update_all(req, self.req_id, expected)
|
||||
|
||||
self.assertEqual(expected, res_dict)
|
||||
@ -477,7 +477,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'meta': {}}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update_all, req, self.req_id,
|
||||
@ -491,7 +491,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'metadata': ['asdf']}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update_all, req, self.req_id,
|
||||
@ -503,7 +503,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
body = {'metadata': {'key10': 'value10'}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.update_all, req, '100', body)
|
||||
@ -524,7 +524,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res_dict = self.controller.update(req, self.req_id, 'key1', body)
|
||||
expected = {'meta': {'key1': 'value1'}}
|
||||
@ -537,7 +537,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'/v1.1/fake/snapshots/asdf/metadata/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
@ -562,7 +562,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -583,7 +583,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {("a" * 260): "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
@ -605,7 +605,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": ("a" * 260)}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
@ -618,7 +618,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1", "key2": "value2"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -631,7 +631,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/bad')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -656,18 +656,18 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
|
||||
# test for long key
|
||||
data = {"metadata": {"a" * 260: "value1"}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.create, req, self.req_id, data)
|
||||
|
||||
# test for long value
|
||||
data = {"metadata": {"key": "v" * 260}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.create, req, self.req_id, data)
|
||||
|
||||
# test for empty key.
|
||||
data = {"metadata": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, self.req_id, data)
|
||||
|
@ -181,7 +181,7 @@ class VolumeTypesSerializerTest(test.TestCase):
|
||||
|
||||
# Just getting some input data
|
||||
vtypes = return_volume_types_get_all_types(None)
|
||||
text = serializer.serialize({'volume_types': vtypes.values()})
|
||||
text = serializer.serialize({'volume_types': list(vtypes.values())})
|
||||
|
||||
tree = etree.fromstring(text)
|
||||
|
||||
|
@ -265,7 +265,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
body = {"metadata": {"key1": "value1",
|
||||
"key2": "value2",
|
||||
"key3": "value3", }}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -298,7 +298,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
"key2": "value2",
|
||||
"key3": "value3",
|
||||
"KEY4": "value4"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -323,7 +323,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -335,7 +335,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {("a" * 260): "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -353,7 +353,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.content_type = "application/json"
|
||||
body = {"metadata": {"key9": "value9"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.create, req, self.req_id, body)
|
||||
|
||||
@ -372,7 +372,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
'KEY20': 'value20',
|
||||
},
|
||||
}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -409,7 +409,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
'KEY20': 'value20',
|
||||
},
|
||||
}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -428,7 +428,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'metadata': {}}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -446,7 +446,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": ("a" * 260)}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
@ -466,7 +466,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'meta': {}}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update_all, req, self.req_id,
|
||||
@ -481,7 +481,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'metadata': ['asdf']}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -497,7 +497,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
body = {'metadata': {'key10': 'value10'}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.update_all, req, '100', body)
|
||||
@ -510,7 +510,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
@ -528,7 +528,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank('/v1.1/fake/volumes/asdf/metadata/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
@ -554,7 +554,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
@ -575,7 +575,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {("a" * 260): "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
@ -594,7 +594,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1", "key2": "value2"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -607,7 +607,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/bad')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -625,7 +625,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
|
||||
# test for long key
|
||||
data = {"metadata": {"a" * 260: "value1"}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -636,7 +636,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
|
||||
# test for long value
|
||||
data = {"metadata": {"key": "v" * 260}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -647,7 +647,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
|
||||
# test for empty key.
|
||||
data = {"metadata": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
|
@ -575,7 +575,7 @@ class WsgiLimiterTest(BaseLimitTestSuite):
|
||||
|
||||
def _request_data(self, verb, path):
|
||||
"""Get data describing a limit request verb/path."""
|
||||
return jsonutils.dumps({"verb": verb, "path": path})
|
||||
return jsonutils.dump_as_bytes({"verb": verb, "path": path})
|
||||
|
||||
def _request(self, verb, url, username=None):
|
||||
"""POST request to given url by given username.
|
||||
@ -641,9 +641,11 @@ class FakeHttplibSocket(object):
|
||||
|
||||
def __init__(self, response_string):
|
||||
"""Initialize new `FakeHttplibSocket`."""
|
||||
self._buffer = six.StringIO(response_string)
|
||||
if isinstance(response_string, six.text_type):
|
||||
response_string = response_string.encode('utf-8')
|
||||
self._buffer = six.BytesIO(response_string)
|
||||
|
||||
def makefile(self, _mode, _other):
|
||||
def makefile(self, mode, *args):
|
||||
"""Returns the socket's internal buffer."""
|
||||
return self._buffer
|
||||
|
||||
@ -761,8 +763,9 @@ class WsgiLimiterProxyTest(BaseLimitTestSuite):
|
||||
delay, error = self.proxy.check_for_delay("GET", "/delayed")
|
||||
error = error.strip()
|
||||
|
||||
expected = ("60.00", "403 Forbidden\n\nOnly 1 GET request(s) can be "
|
||||
"made to /delayed every minute.")
|
||||
expected = ("60.00",
|
||||
b"403 Forbidden\n\nOnly 1 GET request(s) can be "
|
||||
b"made to /delayed every minute.")
|
||||
|
||||
self.assertEqual(expected, (delay, error))
|
||||
|
||||
@ -834,7 +837,7 @@ class LimitsXMLSerializationTest(test.TestCase):
|
||||
"absolute": {}}}
|
||||
|
||||
output = serializer.serialize(fixture)
|
||||
has_dec = output.startswith("<?xml version='1.0' encoding='UTF-8'?>")
|
||||
has_dec = output.startswith(b"<?xml version='1.0' encoding='UTF-8'?>")
|
||||
self.assertTrue(has_dec)
|
||||
|
||||
def test_index(self):
|
||||
|
@ -293,7 +293,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
body = {"metadata": {"key1": "value1",
|
||||
"key2": "value2",
|
||||
"key3": "value3"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
res_dict = self.controller.create(req, self.req_id, body)
|
||||
self.assertEqual(body, res_dict)
|
||||
|
||||
@ -327,7 +327,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
"key2": "value2",
|
||||
"key3": "value3",
|
||||
"KEY4": "value4"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
res_dict = self.controller.create(req, self.req_id, body)
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
@ -347,7 +347,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -359,7 +359,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {("a" * 260): "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -376,7 +376,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.content_type = "application/json"
|
||||
body = {"metadata": {"key9": "value9"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.create, req, self.req_id, body)
|
||||
|
||||
@ -403,7 +403,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'KEY20': 'value20',
|
||||
},
|
||||
}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
res_dict = self.controller.update_all(req, self.req_id, expected)
|
||||
|
||||
self.assertEqual(expected, res_dict)
|
||||
@ -443,7 +443,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'KEY20': 'value20',
|
||||
},
|
||||
}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
res_dict = self.controller.update_all(req, self.req_id, body)
|
||||
|
||||
self.assertEqual(expected, res_dict)
|
||||
@ -466,7 +466,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'metadata': {}}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
res_dict = self.controller.update_all(req, self.req_id, expected)
|
||||
|
||||
self.assertEqual(expected, res_dict)
|
||||
@ -478,7 +478,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'meta': {}}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update_all, req, self.req_id,
|
||||
@ -491,7 +491,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'metadata': ['asdf']}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update_all, req, self.req_id,
|
||||
@ -503,7 +503,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
body = {'metadata': {'key10': 'value10'}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.update_all, req, '100', body)
|
||||
@ -524,7 +524,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res_dict = self.controller.update(req, self.req_id, 'key1', body)
|
||||
expected = {'meta': {'key1': 'value1'}}
|
||||
@ -537,7 +537,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'/v2/fake/snapshots/asdf/metadata/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
@ -562,7 +562,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -583,7 +583,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {("a" * 260): "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
@ -605,7 +605,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": ("a" * 260)}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
@ -618,7 +618,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1", "key2": "value2"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -631,7 +631,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/bad')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -656,18 +656,18 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
|
||||
# test for long key
|
||||
data = {"metadata": {"a" * 260: "value1"}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.create, req, self.req_id, data)
|
||||
|
||||
# test for long value
|
||||
data = {"metadata": {"key": "v" * 260}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.create, req, self.req_id, data)
|
||||
|
||||
# test for empty key.
|
||||
data = {"metadata": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, self.req_id, data)
|
||||
|
@ -54,7 +54,7 @@ def return_volume_types_get_all_types(context, filters=None, marker=None,
|
||||
vol_type_3=stub_volume_type(3)
|
||||
)
|
||||
if list_result:
|
||||
return result.values()
|
||||
return list(result.values())
|
||||
return result
|
||||
|
||||
|
||||
@ -416,7 +416,7 @@ class VolumeTypesSerializerTest(test.TestCase):
|
||||
|
||||
# Just getting some input data
|
||||
vtypes = return_volume_types_get_all_types(None)
|
||||
text = serializer.serialize({'volume_types': vtypes.values()})
|
||||
text = serializer.serialize({'volume_types': list(vtypes.values())})
|
||||
|
||||
tree = etree.fromstring(text)
|
||||
|
||||
|
@ -277,7 +277,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
body = {"metadata": {"key1": "value1",
|
||||
"key2": "value2",
|
||||
"key3": "value3", }}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -299,7 +299,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
body = {"metadata": {"key1": "value1",
|
||||
"key2": "value2",
|
||||
"key3": "value3", }}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -333,7 +333,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
"key2": "value2",
|
||||
"key3": "value3",
|
||||
"KEY4": "value4"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -358,7 +358,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -370,7 +370,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {("a" * 260): "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -388,7 +388,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.content_type = "application/json"
|
||||
body = {"metadata": {"key9": "value9"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.create, req, self.req_id, body)
|
||||
|
||||
@ -407,7 +407,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
'KEY20': 'value20',
|
||||
},
|
||||
}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -432,7 +432,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
'KEY20': 'value20',
|
||||
},
|
||||
}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -471,7 +471,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
'KEY20': 'value20',
|
||||
},
|
||||
}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -490,7 +490,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'metadata': {}}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -507,7 +507,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'meta': {}}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update_all, req, self.req_id,
|
||||
@ -520,7 +520,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
expected = {'metadata': ['asdf']}
|
||||
req.body = jsonutils.dumps(expected)
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update_all, req, self.req_id,
|
||||
@ -532,7 +532,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.method = 'PUT'
|
||||
req.content_type = "application/json"
|
||||
body = {'metadata': {'key10': 'value10'}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.update_all, req, '100', body)
|
||||
@ -545,7 +545,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
@ -565,7 +565,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
@ -584,7 +584,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank('/v2/fake/volumes/asdf/metadata/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
@ -610,7 +610,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
@ -631,7 +631,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {("a" * 260): "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
@ -652,7 +652,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": ("a" * 260)}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
@ -671,7 +671,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1", "key2": "value2"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -684,7 +684,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/bad')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -702,7 +702,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
|
||||
# test for long key
|
||||
data = {"metadata": {"a" * 260: "value1"}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -713,7 +713,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
|
||||
# test for long value
|
||||
data = {"metadata": {"key": "v" * 260}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
@ -724,7 +724,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
|
||||
# test for empty key.
|
||||
data = {"metadata": {"": "value1"}}
|
||||
req.body = jsonutils.dumps(data)
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
|
@ -4,7 +4,8 @@ cinder.tests.unit.api.test_common
|
||||
cinder.tests.unit.api.test_extensions
|
||||
cinder.tests.unit.api.test_versions
|
||||
cinder.tests.unit.api.test_xmlutil
|
||||
cinder.tests.unit.api.v2.test_volumes
|
||||
cinder.tests.unit.api.v1
|
||||
cinder.tests.unit.api.v2
|
||||
cinder.tests.unit.backup.drivers.test_backup_glusterfs
|
||||
cinder.tests.unit.backup.drivers.test_backup_nfs
|
||||
cinder.tests.unit.backup.drivers.test_backup_posix
|
||||
|
Loading…
Reference in New Issue
Block a user