diff --git a/ceilometer/tests/alarm/test_rpc.py b/ceilometer/tests/alarm/test_rpc.py index edbff37d9..c3b09d36f 100644 --- a/ceilometer/tests/alarm/test_rpc.py +++ b/ceilometer/tests/alarm/test_rpc.py @@ -23,7 +23,7 @@ import mock from ceilometer.alarm import rpc as rpc_alarm from ceilometer.openstack.common.fixture import config -from ceilometer.openstack.common.fixture import moxstubout +from ceilometer.openstack.common.fixture import mockpatch from ceilometer.openstack.common import rpc from ceilometer.openstack.common import test from ceilometer.openstack.common import timeutils @@ -31,15 +31,16 @@ from ceilometer.storage.models import Alarm as AlarmModel class TestRPCAlarmNotifier(test.BaseTestCase): - def faux_cast(self, context, topic, msg): + def fake_cast(self, context, topic, msg): self.notified.append((topic, msg)) self.CONF = self.useFixture(config.Config()).conf def setUp(self): super(TestRPCAlarmNotifier, self).setUp() self.notified = [] - self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs - self.stubs.Set(rpc, 'cast', self.faux_cast) + self.useFixture(mockpatch.PatchObject( + rpc, 'cast', + side_effect=self.fake_cast)) self.notifier = rpc_alarm.RPCAlarmNotifier() self.alarms = [ AlarmClient(None, info={ @@ -123,14 +124,15 @@ class TestRPCAlarmNotifier(test.BaseTestCase): class TestRPCAlarmPartitionCoordination(test.BaseTestCase): - def faux_fanout_cast(self, context, topic, msg): + def fake_fanout_cast(self, context, topic, msg): self.notified.append((topic, msg)) def setUp(self): super(TestRPCAlarmPartitionCoordination, self).setUp() self.notified = [] - self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs - self.stubs.Set(rpc, 'fanout_cast', self.faux_fanout_cast) + self.useFixture(mockpatch.PatchObject( + rpc, 'fanout_cast', + side_effect=self.fake_fanout_cast)) self.ordination = rpc_alarm.RPCAlarmPartitionCoordination() self.alarms = [mock.MagicMock(), mock.MagicMock()] diff --git a/ceilometer/tests/central/test_manager.py b/ceilometer/tests/central/test_manager.py index 12ad1e7da..573c73aeb 100644 --- a/ceilometer/tests/central/test_manager.py +++ b/ceilometer/tests/central/test_manager.py @@ -18,11 +18,10 @@ """Tests for ceilometer/central/manager.py """ -from keystoneclient.v2_0 import client as ksclient import mock from ceilometer.central import manager -from ceilometer.openstack.common.fixture import moxstubout +from ceilometer.openstack.common.fixture import mockpatch from ceilometer.openstack.common import test from ceilometer.tests import agentbase @@ -42,8 +41,6 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase): def setUp(self): super(TestRunTasks, self).setUp() - self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs - self.stubs.Set(ksclient, 'Client', lambda *args, **kwargs: None) - - def tearDown(self): - super(TestRunTasks, self).tearDown() + self.useFixture(mockpatch.Patch( + 'keystoneclient.v2_0.client.Client', + return_value=None)) diff --git a/ceilometer/tests/image/test_glance.py b/ceilometer/tests/image/test_glance.py index 57309dc13..0908837c0 100644 --- a/ceilometer/tests/image/test_glance.py +++ b/ceilometer/tests/image/test_glance.py @@ -21,7 +21,7 @@ import mock from ceilometer.central import manager from ceilometer.image import glance from ceilometer.openstack.common import context -from ceilometer.openstack.common.fixture import moxstubout +from ceilometer.openstack.common.fixture import mockpatch from ceilometer.openstack.common import test IMAGE_LIST = [ @@ -128,11 +128,11 @@ class TestImagePollster(test.BaseTestCase): @mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock()) def setUp(self): super(TestImagePollster, self).setUp() - self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs self.context = context.get_admin_context() self.manager = TestManager() - self.stubs.Set(glance._Base, 'get_glance_client', - self.fake_get_glance_client) + self.useFixture(mockpatch.PatchObject( + glance._Base, 'get_glance_client', + side_effect=self.fake_get_glance_client)) def test_iter_images(self): # Tests whether the iter_images method returns an unique image