diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py index 2b7bf3ab0c..4ffd742e44 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -19,7 +19,7 @@ import uuid from cinderclient import exceptions as cinder_exception from eventlet import event as eventlet_event import mock -import mox +from mox3 import mox from oslo.config import cfg from oslo import messaging from oslo.utils import importutils @@ -132,10 +132,12 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): def test_allocate_network_maintains_context(self): # override tracker with a version that doesn't need the database: class FakeResourceTracker(object): - def instance_claim(self, context, instance, limits): - return mox.MockAnything() + @staticmethod + def instance_claim(context, instance, limits): + return mock.MagicMock() self.mox.StubOutWithMock(self.compute, '_get_resource_tracker') + self.mox.StubOutWithMock(self.compute, '_reschedule_or_error') self.mox.StubOutWithMock(self.compute, '_allocate_network') self.mox.StubOutWithMock(objects.BlockDeviceMappingList, 'get_by_instance_uuid') @@ -154,6 +156,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): def fake_allocate(context, *args, **kwargs): if context.is_admin: self.admin_context = True + raise test.TestingException() # NOTE(vish): The nice mox parameter matchers here don't work well # because they raise an exception that gets wrapped by @@ -164,16 +167,22 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()).WithSideEffects(fake_allocate) + self.compute._reschedule_or_error(mox.IgnoreArg(), instance, + mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg(), + mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg(), + mox.IgnoreArg(), mox.IgnoreArg(), + mox.IgnoreArg()) + self.mox.ReplayAll() - instance, nw_info = self.compute._build_instance(self.context, {}, {}, - None, None, None, True, - node, instance, - {}, False) + self.assertRaises(test.TestingException, + self.compute._build_instance, + self.context, {}, {}, + None, None, None, True, + node, instance, + {}, False) self.assertFalse(self.admin_context, "_allocate_network called with admin context") - self.assertEqual(vm_states.BUILDING, instance.vm_state) - self.assertEqual(task_states.BLOCK_DEVICE_MAPPING, instance.task_state) def test_reschedule_maintains_context(self): # override tracker with a version that causes a reschedule diff --git a/nova/tests/unit/virt/hyperv/test_hypervapi.py b/nova/tests/unit/virt/hyperv/test_hypervapi.py index a116b757e8..35f1253b3a 100644 --- a/nova/tests/unit/virt/hyperv/test_hypervapi.py +++ b/nova/tests/unit/virt/hyperv/test_hypervapi.py @@ -22,7 +22,7 @@ import time import uuid import mock -import mox +from mox3 import mox from oslo.config import cfg from oslo.utils import units diff --git a/test-requirements.txt b/test-requirements.txt index 4921ef1bb1..e807dd2e67 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,7 +8,6 @@ discover fixtures>=0.3.14 libvirt-python>=1.2.5 # LGPLv2+ mock>=1.0 -mox>=0.5.3 mox3>=0.7.0 MySQL-python psycopg2