summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Smith <dansmith@redhat.com>2015-02-03 15:38:53 -0800
committerDan Smith <dansmith@redhat.com>2015-02-03 15:57:54 -0800
commit20e7c0b63fff0e7d6f939709bdca4f1040053130 (patch)
treea14dd1be834a8dbf78a2748d38c941c71bb7a4b2
parent089cea5b7c4ec7a6dd24dadc64858e4a9832ba30 (diff)
downloadnova-20e7c0b63fff0e7d6f939709bdca4f1040053130.tar.gz
Fix bad mocking of methods on Instance
Since the objects come and go from the registry during tests, mocking a staticmethod via path results in us not seeing the mock on the remote side. Change-Id: I046c30c5852c17012c8938b31a7d1d6bacb9e7f2 Partial-Bug: #1417678
-rw-r--r--nova/tests/unit/objects/test_instance.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/nova/tests/unit/objects/test_instance.py b/nova/tests/unit/objects/test_instance.py
index 25716b39e9..d36d1d8e56 100644
--- a/nova/tests/unit/objects/test_instance.py
+++ b/nova/tests/unit/objects/test_instance.py
@@ -421,7 +421,7 @@ class _TestInstanceObject(object):
self.assertTrue(save_mock.called)
@mock.patch('nova.db.instance_update_and_get_original')
- @mock.patch('nova.objects.Instance._from_db_object')
+ @mock.patch.object(objects.Instance, '_from_db_object')
def test_save_does_not_refresh_pci_devices(self, mock_fdo, mock_update):
# NOTE(danms): This tests that we don't update the pci_devices
# field from the contents of the database. This is not because we
@@ -438,7 +438,7 @@ class _TestInstanceObject(object):
@mock.patch('nova.db.instance_extra_update_by_uuid')
@mock.patch('nova.db.instance_update_and_get_original')
- @mock.patch('nova.objects.Instance._from_db_object')
+ @mock.patch.object(objects.Instance, '_from_db_object')
def test_save_updates_numa_topology(self, mock_fdo, mock_update,
mock_extra_update):
fake_obj_numa_topology = objects.InstanceNUMATopology(cells=[
@@ -970,7 +970,7 @@ class _TestInstanceObject(object):
inst.fault
mock_load.assert_called_once_with()
- @mock.patch('nova.objects.Instance.get_by_uuid')
+ @mock.patch.object(objects.Instance, 'get_by_uuid')
def test_load_generic(self, mock_get):
inst2 = instance.Instance(metadata={'foo': 'bar'})
mock_get.return_value = inst2