Merge "object: serialize set to list"
This commit is contained in:
commit
23d1040dfb
@ -783,11 +783,13 @@ class NovaObjectSerializer(messaging.NoOpSerializer):
|
||||
return iterable(**{k: action_fn(context, v)
|
||||
for k, v in six.iteritems(values)})
|
||||
else:
|
||||
# NOTE(danms): A set can't have an unhashable value inside, such as
|
||||
# a dict. Convert sets to tuples, which is fine, since we can't
|
||||
# send them over RPC anyway.
|
||||
# NOTE(danms, gibi) A set can't have an unhashable value inside,
|
||||
# such as a dict. Convert the set to list, which is fine, since we
|
||||
# can't send them over RPC anyway. We convert it to list as this
|
||||
# way there will be no semantic change between the fake rpc driver
|
||||
# used in functional test and a normal rpc driver.
|
||||
if iterable == set:
|
||||
iterable = tuple
|
||||
iterable = list
|
||||
return iterable([action_fn(context, value) for value in values])
|
||||
|
||||
def serialize_entity(self, context, entity):
|
||||
|
@ -1013,6 +1013,10 @@ class TestObjectSerializer(_BaseTestCase):
|
||||
for thing in (1, 'foo', [1, 2], {'foo': 'bar'}):
|
||||
self.assertEqual(thing, ser.deserialize_entity(None, thing))
|
||||
|
||||
def test_serialize_set_to_list(self):
|
||||
ser = base.NovaObjectSerializer()
|
||||
self.assertEqual([1, 2], ser.serialize_entity(None, set([1, 2])))
|
||||
|
||||
def _test_deserialize_entity_newer(self, obj_version, backported_to,
|
||||
my_version='1.6'):
|
||||
ser = base.NovaObjectSerializer()
|
||||
|
Loading…
x
Reference in New Issue
Block a user