Replace mox with mock in alarm,central,image tests
Replace mox with mock in: * tests.alarm.test_rpc * tests.central.test_manager * tests.image.test_glance Change-Id: Icb71ccc09c26344c9814ff1f7c958101edd636e7
This commit is contained in:
parent
4a638fab63
commit
cc99da5070
@ -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()]
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user