summaryrefslogtreecommitdiff
path: root/nova/tests/unit/objects
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2020-10-05 13:48:19 +0100
committerStephen Finucane <stephenfin@redhat.com>2020-10-12 10:09:10 +0100
commit12cc805d3687fcc27023326c7602deae9c7ac2c4 (patch)
tree659c1a389bdf8eb1d900e830f5c5c94398302d80 /nova/tests/unit/objects
parent261de76104ca67bed3ea6cdbcaaab0e44030f1e2 (diff)
downloadnova-12cc805d3687fcc27023326c7602deae9c7ac2c4.tar.gz
objects: Fix issue in exception type
We were attempting to pass a 'target_version' variable into an exception message. 'target_version' is a tuple which means it's expanded out resulting in the following error: TypeError: not all arguments converted during string formatting Fix this. Change-Id: I6063b2108ae38776d034fd7a4c3aa88dc66a084f Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Closes-Bug: #1898554
Diffstat (limited to 'nova/tests/unit/objects')
-rw-r--r--nova/tests/unit/objects/test_instance_numa.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/nova/tests/unit/objects/test_instance_numa.py b/nova/tests/unit/objects/test_instance_numa.py
index 9d7f7d1a6b..059f740ea8 100644
--- a/nova/tests/unit/objects/test_instance_numa.py
+++ b/nova/tests/unit/objects/test_instance_numa.py
@@ -179,11 +179,24 @@ class _TestInstanceNUMACell(object):
topo_obj = objects.InstanceNUMACell(
cpuset=set(), pcpuset=set([0, 1]),
cpuset_reserved=set([1, 2]),
- cpu_policy=fields.CPUAllocationPolicy.DEDICATED)
+ cpu_policy=fields.CPUAllocationPolicy.MIXED,
+ )
versions = ovo_base.obj_tree_get_versions('InstanceNUMACell')
data = lambda x: x['nova_object.data']
primitive = data(topo_obj.obj_to_primitive(
+ target_version='1.6', version_manifest=versions))
+ self.assertEqual(
+ fields.CPUAllocationPolicy.MIXED, primitive['cpu_policy'])
+
+ self.assertRaises(
+ exception.ObjectActionError,
+ topo_obj.obj_to_primitive,
+ target_version='1.5', version_manifest=versions)
+
+ # set this to something compatible with < 1.6 so we can keep testing
+ topo_obj.cpu_policy = fields.CPUAllocationPolicy.DEDICATED
+ primitive = data(topo_obj.obj_to_primitive(
target_version='1.5', version_manifest=versions))
self.assertIn('pcpuset', primitive)