Merge "Python3: fix glance.tests.unit.v2.test_registry_client"
This commit is contained in:
commit
7c64dc7071
@ -456,7 +456,7 @@ class BaseClient(object):
|
||||
return method.lower() in ('post', 'put')
|
||||
|
||||
def _simple(body):
|
||||
return body is None or isinstance(body, six.string_types)
|
||||
return body is None or isinstance(body, bytes)
|
||||
|
||||
def _filelike(body):
|
||||
return hasattr(body, 'read')
|
||||
|
@ -813,7 +813,7 @@ class JSONResponseSerializer(object):
|
||||
return jsonutils.to_primitive(obj)
|
||||
|
||||
def to_json(self, data):
|
||||
return jsonutils.dumps(data, default=self._sanitizer)
|
||||
return jsonutils.dump_as_bytes(data, default=self._sanitizer)
|
||||
|
||||
def default(self, response, result):
|
||||
response.content_type = 'application/json'
|
||||
|
@ -265,7 +265,7 @@ class TestRPCJSONSerializer(test_utils.BaseTestCase):
|
||||
|
||||
def test_to_json(self):
|
||||
fixture = {"key": "value"}
|
||||
expected = '{"key": "value"}'
|
||||
expected = b'{"key": "value"}'
|
||||
actual = rpc.RPCJSONSerializer().to_json(fixture)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
|
@ -377,13 +377,13 @@ class JSONResponseSerializerTest(test_utils.BaseTestCase):
|
||||
|
||||
def test_to_json(self):
|
||||
fixture = {"key": "value"}
|
||||
expected = '{"key": "value"}'
|
||||
expected = b'{"key": "value"}'
|
||||
actual = wsgi.JSONResponseSerializer().to_json(fixture)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_to_json_with_date_format_value(self):
|
||||
fixture = {"date": datetime.datetime(1901, 3, 8, 2)}
|
||||
expected = '{"date": "1901-03-08T02:00:00.000000"}'
|
||||
expected = b'{"date": "1901-03-08T02:00:00.000000"}'
|
||||
actual = wsgi.JSONResponseSerializer().to_json(fixture)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@ -397,7 +397,7 @@ class JSONResponseSerializerTest(test_utils.BaseTestCase):
|
||||
|
||||
def test_to_json_with_set(self):
|
||||
fixture = set(["foo"])
|
||||
expected = '["foo"]'
|
||||
expected = b'["foo"]'
|
||||
actual = wsgi.JSONResponseSerializer().to_json(fixture)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
|
@ -26,6 +26,7 @@ import uuid
|
||||
|
||||
from mock import patch
|
||||
from oslo_utils import timeutils
|
||||
from six.moves import reload_module
|
||||
|
||||
from glance.common import config
|
||||
from glance.common import exception
|
||||
@ -592,7 +593,7 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
|
||||
next_state = 'saving'
|
||||
fixture = {'name': 'fake image',
|
||||
'disk_format': 'vmdk',
|
||||
'min_disk': str(2 ** 31 + 1),
|
||||
'min_disk': 2 ** 31 + 1,
|
||||
'status': next_state}
|
||||
|
||||
image = self.client.image_get(image_id=UUID2)
|
||||
@ -611,7 +612,7 @@ class TestRegistryV2Client(base.IsolatedUnitTest,
|
||||
next_state = 'saving'
|
||||
fixture = {'name': 'fake image',
|
||||
'disk_format': 'vmdk',
|
||||
'min_ram': str(2 ** 31 + 1),
|
||||
'min_ram': 2 ** 31 + 1,
|
||||
'status': next_state}
|
||||
|
||||
image = self.client.image_get(image_id=UUID2)
|
||||
@ -731,7 +732,7 @@ class TestRegistryV2ClientApi(base.IsolatedUnitTest):
|
||||
def setUp(self):
|
||||
"""Establish a clean test environment"""
|
||||
super(TestRegistryV2ClientApi, self).setUp()
|
||||
reload(rapi)
|
||||
reload_module(rapi)
|
||||
|
||||
def tearDown(self):
|
||||
"""Clear the test environment"""
|
||||
|
1
tox.ini
1
tox.ini
@ -81,6 +81,7 @@ commands =
|
||||
glance.tests.unit.v2.test_images_resource \
|
||||
glance.tests.unit.v2.test_metadef_resources \
|
||||
glance.tests.unit.v2.test_registry_api \
|
||||
glance.tests.unit.v2.test_registry_client \
|
||||
glance.tests.unit.v2.test_schemas_resource \
|
||||
glance.tests.unit.v2.test_tasks_resource
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user