From 6a422828aeb9707bdcc323075c598962d87d8897 Mon Sep 17 00:00:00 2001 From: Markus Zoeller Date: Wed, 25 May 2016 14:01:54 +0200 Subject: [PATCH] Fix "KeyError: u'instance_id'" in string format operation Commit 56ac4418 removed the usage of mox in favor of mock. By mistake it introduced the mocking of the kwarg "instance_uuid" which isn't part of the format string of the InstanceNotFound exception. The error looks like this: Exception in string format operation Traceback (most recent call last): File "nova/exception.py", line 140, in __init__ message = self.msg_fmt % kwargs KeyError: u'instance_id' This patch changes the mock to use "instance_id", which is the correct kwarg for the format string of the InstanceNotFound exception. It also uses the correct "uuids.instance" for this mock. Change-Id: I6745075e186ad150a8ff1765dbece267e5cc2c5b --- .../unit/api/openstack/compute/test_server_start_stop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/tests/unit/api/openstack/compute/test_server_start_stop.py b/nova/tests/unit/api/openstack/compute/test_server_start_stop.py index 6469ab25b103..86cc105bd217 100644 --- a/nova/tests/unit/api/openstack/compute/test_server_start_stop.py +++ b/nova/tests/unit/api/openstack/compute/test_server_start_stop.py @@ -132,7 +132,7 @@ class ServerStartStopTestV21(test.TestCase): @mock.patch.object(db, 'instance_get_by_uuid', side_effect=exception.InstanceNotFound( - instance_uuid=uuids.instance)) + instance_id=uuids.instance)) def test_start_with_bogus_id(self, get_mock): body = dict(start="") self.assertRaises(webob.exc.HTTPNotFound, @@ -140,7 +140,7 @@ class ServerStartStopTestV21(test.TestCase): @mock.patch.object(db, 'instance_get_by_uuid', side_effect=exception.InstanceNotFound( - instance_uuid=uuids.InstanceNotFound)) + instance_id=uuids.instance)) def test_stop_with_bogus_id(self, get_mock): body = dict(stop="") self.assertRaises(webob.exc.HTTPNotFound,