Merge "Stop using mox in unit/*.py tests (1/2)"

This commit is contained in:
Jenkins 2016-08-30 10:51:16 +00:00 committed by Gerrit Code Review
commit 6ce540758d
5 changed files with 22 additions and 21 deletions

View File

@ -187,7 +187,7 @@ class TestCase(testtools.TestCase):
self.injected = []
self._services = []
fake_notifier.stub_notifier(self.stubs)
fake_notifier.mock_notifier(self)
self.override_config('fatal_exception_format_errors', True)
# This will be cleaned up by the NestedTempfile fixture

View File

@ -64,13 +64,14 @@ class FakeNotifier(object):
del self.notifications[:]
def stub_notifier(stubs):
stubs.Set(messaging, 'Notifier', FakeNotifier)
def mock_notifier(testcase):
testcase.mock_object(messaging, 'Notifier', FakeNotifier)
if rpc.NOTIFIER:
serializer = getattr(rpc.NOTIFIER, '_serializer', None)
stubs.Set(rpc, 'NOTIFIER', FakeNotifier(rpc.NOTIFIER.transport,
rpc.NOTIFIER.publisher_id,
serializer=serializer))
testcase.mock_object(rpc, 'NOTIFIER',
FakeNotifier(rpc.NOTIFIER.transport,
rpc.NOTIFIER.publisher_id,
serializer=serializer))
def get_fake_notifier(service=None, host=None, publisher_id=None):

View File

@ -397,9 +397,9 @@ class EMCCoprHDISCSIDriverTest(test.TestCase):
self.volume_type_id = self.create_coprhd_volume_type()
self.stubs.Set(coprhd_iscsi.EMCCoprHDISCSIDriver,
'_get_common_driver',
self._get_mocked_common_driver)
self.mock_object(coprhd_iscsi.EMCCoprHDISCSIDriver,
'_get_common_driver',
self._get_mocked_common_driver)
self.driver = coprhd_iscsi.EMCCoprHDISCSIDriver(
configuration=self.configuration)
@ -564,9 +564,9 @@ class EMCCoprHDFCDriverTest(test.TestCase):
self.volume_type_id = self.create_coprhd_volume_type()
self.stubs.Set(coprhd_fc.EMCCoprHDFCDriver,
'_get_common_driver',
self._get_mocked_common_driver)
self.mock_object(coprhd_fc.EMCCoprHDFCDriver,
'_get_common_driver',
self._get_mocked_common_driver)
self.driver = coprhd_fc.EMCCoprHDFCDriver(
configuration=self.configuration)
@ -760,12 +760,12 @@ class EMCCoprHDScaleIODriverTest(test.TestCase):
self.volume_type_id = self.create_coprhd_volume_type()
self.stubs.Set(coprhd_scaleio.EMCCoprHDScaleIODriver,
'_get_common_driver',
self._get_mocked_common_driver)
self.stubs.Set(coprhd_scaleio.EMCCoprHDScaleIODriver,
'_get_client_id',
self._get_client_id)
self.mock_object(coprhd_scaleio.EMCCoprHDScaleIODriver,
'_get_common_driver',
self._get_mocked_common_driver)
self.mock_object(coprhd_scaleio.EMCCoprHDScaleIODriver,
'_get_client_id',
self._get_client_id)
self.driver = coprhd_scaleio.EMCCoprHDScaleIODriver(
configuration=self.configuration)

View File

@ -208,7 +208,7 @@ class FSSDriverTestCase(test.TestCase):
self.mock_config.san_is_local = False
self.mock_config.fss_debug = False
self.mock_config.additional_retry_list = False
self.stubs.Set(time, 'sleep', Fake_sleep)
self.mock_object(time, 'sleep', Fake_sleep)
class TestFSSISCSIDriver(FSSDriverTestCase):

View File

@ -196,8 +196,8 @@ class VolumeRpcAPITestCase(test.TestCase):
if expected_retval:
return expected_retval
self.stubs.Set(rpcapi.client, "prepare", _fake_prepare_method)
self.stubs.Set(rpcapi.client, rpc_method, _fake_rpc_method)
self.mock_object(rpcapi.client, "prepare", _fake_prepare_method)
self.mock_object(rpcapi.client, rpc_method, _fake_rpc_method)
retval = getattr(rpcapi, method)(ctxt, **kwargs)