Merge "Replace mox with mock in publisher and pipeline"
This commit is contained in:
commit
631c1fd560
@ -24,7 +24,6 @@ import mock
|
||||
import msgpack
|
||||
|
||||
from ceilometer.openstack.common.fixture import config
|
||||
from ceilometer.openstack.common.fixture import moxstubout
|
||||
from ceilometer.openstack.common import network_utils
|
||||
from ceilometer.openstack.common import test
|
||||
from ceilometer.publisher import udp
|
||||
@ -103,15 +102,13 @@ class TestUDPPublisher(test.BaseTestCase):
|
||||
def _fake_socket_socket(family, type):
|
||||
def record_data(msg, dest):
|
||||
published.append((msg, dest))
|
||||
udp_socket = self.mox.CreateMockAnything()
|
||||
udp_socket = mock.Mock()
|
||||
udp_socket.sendto = record_data
|
||||
self.mox.ReplayAll()
|
||||
return udp_socket
|
||||
return _fake_socket_socket
|
||||
|
||||
def setUp(self):
|
||||
super(TestUDPPublisher, self).setUp()
|
||||
self.mox = self.useFixture(moxstubout.MoxStubout()).mox
|
||||
self.CONF = self.useFixture(config.Config()).conf
|
||||
|
||||
def test_published(self):
|
||||
@ -140,13 +137,13 @@ class TestUDPPublisher(test.BaseTestCase):
|
||||
sorted([dict(d.as_dict()) for d in self.test_data]))
|
||||
|
||||
@staticmethod
|
||||
def _raise_ioerror():
|
||||
def _raise_ioerror(*args):
|
||||
raise IOError
|
||||
|
||||
def _make_broken_socket(self, family, type):
|
||||
udp_socket = self.mox.CreateMockAnything()
|
||||
udp_socket = mock.Mock()
|
||||
udp_socket.sendto = self._raise_ioerror
|
||||
self.mox.ReplayAll()
|
||||
return udp_socket
|
||||
|
||||
def test_publish_error(self):
|
||||
with mock.patch('socket.socket',
|
||||
|
@ -21,7 +21,7 @@ import datetime
|
||||
|
||||
from stevedore import extension
|
||||
|
||||
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 timeutils
|
||||
from ceilometer import pipeline
|
||||
@ -149,16 +149,16 @@ class TestPipeline(test.BaseTestCase):
|
||||
resource_metadata={}
|
||||
)
|
||||
|
||||
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
|
||||
self.stubs.Set(transformer.TransformerExtensionManager,
|
||||
"__init__",
|
||||
self.fake_tem_init)
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
transformer.TransformerExtensionManager, "__init__",
|
||||
side_effect=self.fake_tem_init))
|
||||
|
||||
self.stubs.Set(transformer.TransformerExtensionManager,
|
||||
"get_ext",
|
||||
self.fake_tem_get_ext)
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
transformer.TransformerExtensionManager, "get_ext",
|
||||
side_effect=self.fake_tem_get_ext))
|
||||
|
||||
self.stubs.Set(publisher, 'get_publisher', self.get_publisher)
|
||||
self.useFixture(mockpatch.PatchObject(
|
||||
publisher, 'get_publisher', side_effect=self.get_publisher))
|
||||
|
||||
self.transformer_manager = transformer.TransformerExtensionManager()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user