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.alarm import rpc as rpc_alarm
|
||||||
from ceilometer.openstack.common.fixture import config
|
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 rpc
|
||||||
from ceilometer.openstack.common import test
|
from ceilometer.openstack.common import test
|
||||||
from ceilometer.openstack.common import timeutils
|
from ceilometer.openstack.common import timeutils
|
||||||
@ -31,15 +31,16 @@ from ceilometer.storage.models import Alarm as AlarmModel
|
|||||||
|
|
||||||
|
|
||||||
class TestRPCAlarmNotifier(test.BaseTestCase):
|
class TestRPCAlarmNotifier(test.BaseTestCase):
|
||||||
def faux_cast(self, context, topic, msg):
|
def fake_cast(self, context, topic, msg):
|
||||||
self.notified.append((topic, msg))
|
self.notified.append((topic, msg))
|
||||||
self.CONF = self.useFixture(config.Config()).conf
|
self.CONF = self.useFixture(config.Config()).conf
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestRPCAlarmNotifier, self).setUp()
|
super(TestRPCAlarmNotifier, self).setUp()
|
||||||
self.notified = []
|
self.notified = []
|
||||||
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
|
self.useFixture(mockpatch.PatchObject(
|
||||||
self.stubs.Set(rpc, 'cast', self.faux_cast)
|
rpc, 'cast',
|
||||||
|
side_effect=self.fake_cast))
|
||||||
self.notifier = rpc_alarm.RPCAlarmNotifier()
|
self.notifier = rpc_alarm.RPCAlarmNotifier()
|
||||||
self.alarms = [
|
self.alarms = [
|
||||||
AlarmClient(None, info={
|
AlarmClient(None, info={
|
||||||
@ -123,14 +124,15 @@ class TestRPCAlarmNotifier(test.BaseTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class TestRPCAlarmPartitionCoordination(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))
|
self.notified.append((topic, msg))
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestRPCAlarmPartitionCoordination, self).setUp()
|
super(TestRPCAlarmPartitionCoordination, self).setUp()
|
||||||
self.notified = []
|
self.notified = []
|
||||||
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
|
self.useFixture(mockpatch.PatchObject(
|
||||||
self.stubs.Set(rpc, 'fanout_cast', self.faux_fanout_cast)
|
rpc, 'fanout_cast',
|
||||||
|
side_effect=self.fake_fanout_cast))
|
||||||
self.ordination = rpc_alarm.RPCAlarmPartitionCoordination()
|
self.ordination = rpc_alarm.RPCAlarmPartitionCoordination()
|
||||||
self.alarms = [mock.MagicMock(), mock.MagicMock()]
|
self.alarms = [mock.MagicMock(), mock.MagicMock()]
|
||||||
|
|
||||||
|
@ -18,11 +18,10 @@
|
|||||||
"""Tests for ceilometer/central/manager.py
|
"""Tests for ceilometer/central/manager.py
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from keystoneclient.v2_0 import client as ksclient
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from ceilometer.central import manager
|
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.openstack.common import test
|
||||||
from ceilometer.tests import agentbase
|
from ceilometer.tests import agentbase
|
||||||
|
|
||||||
@ -42,8 +41,6 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestRunTasks, self).setUp()
|
super(TestRunTasks, self).setUp()
|
||||||
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
|
self.useFixture(mockpatch.Patch(
|
||||||
self.stubs.Set(ksclient, 'Client', lambda *args, **kwargs: None)
|
'keystoneclient.v2_0.client.Client',
|
||||||
|
return_value=None))
|
||||||
def tearDown(self):
|
|
||||||
super(TestRunTasks, self).tearDown()
|
|
||||||
|
@ -21,7 +21,7 @@ import mock
|
|||||||
from ceilometer.central import manager
|
from ceilometer.central import manager
|
||||||
from ceilometer.image import glance
|
from ceilometer.image import glance
|
||||||
from ceilometer.openstack.common import context
|
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
|
from ceilometer.openstack.common import test
|
||||||
|
|
||||||
IMAGE_LIST = [
|
IMAGE_LIST = [
|
||||||
@ -128,11 +128,11 @@ class TestImagePollster(test.BaseTestCase):
|
|||||||
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
|
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestImagePollster, self).setUp()
|
super(TestImagePollster, self).setUp()
|
||||||
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
|
|
||||||
self.context = context.get_admin_context()
|
self.context = context.get_admin_context()
|
||||||
self.manager = TestManager()
|
self.manager = TestManager()
|
||||||
self.stubs.Set(glance._Base, 'get_glance_client',
|
self.useFixture(mockpatch.PatchObject(
|
||||||
self.fake_get_glance_client)
|
glance._Base, 'get_glance_client',
|
||||||
|
side_effect=self.fake_get_glance_client))
|
||||||
|
|
||||||
def test_iter_images(self):
|
def test_iter_images(self):
|
||||||
# Tests whether the iter_images method returns an unique image
|
# Tests whether the iter_images method returns an unique image
|
||||||
|
Loading…
Reference in New Issue
Block a user