From 55469df23905c14762f619672c7bcda95f2a909e Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Fri, 10 Jun 2016 11:12:46 +0200 Subject: [PATCH] Stop using mox stubs in tests/unit/fake_notifier Replace 'stubs.Set' with 'stub_out' in the following files. * nova/tests/unit/fake_notifier.py Change-Id: Ie161780e748e3e8f1959a99d6d69e3518ccc958e Implements: blueprint remove-mox-newton --- .../notification_sample_base.py | 3 +- nova/tests/unit/compute/test_compute.py | 2 +- nova/tests/unit/compute/test_compute_utils.py | 2 +- nova/tests/unit/compute/test_host_api.py | 2 +- nova/tests/unit/conductor/test_conductor.py | 2 +- nova/tests/unit/fake_notifier.py | 28 +++++++++---------- nova/tests/unit/objects/test_objects.py | 2 +- nova/tests/unit/test_notifications.py | 2 +- 8 files changed, 21 insertions(+), 22 deletions(-) diff --git a/nova/tests/functional/notification_sample_tests/notification_sample_base.py b/nova/tests/functional/notification_sample_tests/notification_sample_base.py index 56724e4fee1c..9095fe5f14b6 100644 --- a/nova/tests/functional/notification_sample_tests/notification_sample_base.py +++ b/nova/tests/functional/notification_sample_tests/notification_sample_base.py @@ -47,8 +47,7 @@ class NotificationSampleTestBase(test.TestCase): self.api = api_fixture.api self.admin_api = api_fixture.admin_api - - fake_notifier.stub_notifier(self.stubs) + fake_notifier.stub_notifier(self) self.addCleanup(fake_notifier.reset) def _get_notification_sample(self, sample): diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index 303c08091609..1f356b19a22a 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -155,7 +155,7 @@ class BaseTestCase(test.TestCase): fake.set_nodes([NODENAME]) self.flags(use_local=True, group='conductor') - fake_notifier.stub_notifier(self.stubs) + fake_notifier.stub_notifier(self) self.addCleanup(fake_notifier.reset) self.compute = importutils.import_object(CONF.compute_manager) diff --git a/nova/tests/unit/compute/test_compute_utils.py b/nova/tests/unit/compute/test_compute_utils.py index 84398568c13f..39d2b3a44d45 100644 --- a/nova/tests/unit/compute/test_compute_utils.py +++ b/nova/tests/unit/compute/test_compute_utils.py @@ -394,7 +394,7 @@ class UsageInfoTestCase(test.TestCase): self.stubs.Set(network_api.API, 'get_instance_nw_info', fake_get_nw_info) - fake_notifier.stub_notifier(self.stubs) + fake_notifier.stub_notifier(self) self.addCleanup(fake_notifier.reset) self.flags(use_local=True, group='conductor') diff --git a/nova/tests/unit/compute/test_host_api.py b/nova/tests/unit/compute/test_host_api.py index b55f9569c2d9..b73a3b8621dc 100644 --- a/nova/tests/unit/compute/test_host_api.py +++ b/nova/tests/unit/compute/test_host_api.py @@ -35,7 +35,7 @@ class ComputeHostAPITestCase(test.TestCase): super(ComputeHostAPITestCase, self).setUp() self.host_api = compute.HostAPI() self.ctxt = context.get_admin_context() - fake_notifier.stub_notifier(self.stubs) + fake_notifier.stub_notifier(self) self.addCleanup(fake_notifier.reset) def _compare_obj(self, obj, db_obj): diff --git a/nova/tests/unit/conductor/test_conductor.py b/nova/tests/unit/conductor/test_conductor.py index 6b72e37fcbee..ad06bc5d0bdd 100644 --- a/nova/tests/unit/conductor/test_conductor.py +++ b/nova/tests/unit/conductor/test_conductor.py @@ -73,7 +73,7 @@ class _BaseTestCase(object): self.project_id = fakes.FAKE_PROJECT_ID self.context = FakeContext(self.user_id, self.project_id) - fake_notifier.stub_notifier(self.stubs) + fake_notifier.stub_notifier(self) self.addCleanup(fake_notifier.reset) def fake_deserialize_context(serializer, ctxt_dict): diff --git a/nova/tests/unit/fake_notifier.py b/nova/tests/unit/fake_notifier.py index 59432872bc46..f938496e1126 100644 --- a/nova/tests/unit/fake_notifier.py +++ b/nova/tests/unit/fake_notifier.py @@ -75,18 +75,18 @@ class FakeVersionedNotifier(FakeNotifier): 'payload': payload}) -def stub_notifier(stubs): - stubs.Set(messaging, 'Notifier', FakeNotifier) +def stub_notifier(test): + test.stub_out('oslo_messaging.Notifier', FakeNotifier) if rpc.LEGACY_NOTIFIER and rpc.NOTIFIER: - stubs.Set(rpc, 'LEGACY_NOTIFIER', - FakeNotifier(rpc.LEGACY_NOTIFIER.transport, - rpc.LEGACY_NOTIFIER.publisher_id, - serializer=getattr(rpc.LEGACY_NOTIFIER, - '_serializer', - None))) - stubs.Set(rpc, 'NOTIFIER', - FakeVersionedNotifier(rpc.NOTIFIER.transport, - rpc.NOTIFIER.publisher_id, - serializer=getattr(rpc.NOTIFIER, - '_serializer', - None))) + test.stub_out('nova.rpc.LEGACY_NOTIFIER', + FakeNotifier(rpc.LEGACY_NOTIFIER.transport, + rpc.LEGACY_NOTIFIER.publisher_id, + serializer=getattr(rpc.LEGACY_NOTIFIER, + '_serializer', + None))) + test.stub_out('nova.rpc.NOTIFIER', + FakeVersionedNotifier(rpc.NOTIFIER.transport, + rpc.NOTIFIER.publisher_id, + serializer=getattr(rpc.NOTIFIER, + '_serializer', + None))) diff --git a/nova/tests/unit/objects/test_objects.py b/nova/tests/unit/objects/test_objects.py index f97a1aa06819..3c2b323ac360 100644 --- a/nova/tests/unit/objects/test_objects.py +++ b/nova/tests/unit/objects/test_objects.py @@ -239,7 +239,7 @@ class _BaseTestCase(test.TestCase): self.user_id = 'fake-user' self.project_id = 'fake-project' self.context = context.RequestContext(self.user_id, self.project_id) - fake_notifier.stub_notifier(self.stubs) + fake_notifier.stub_notifier(self) self.addCleanup(fake_notifier.reset) # NOTE(danms): register these here instead of at import time diff --git a/nova/tests/unit/test_notifications.py b/nova/tests/unit/test_notifications.py index 1a1f1cf2b1e7..9be8bf7ab504 100644 --- a/nova/tests/unit/test_notifications.py +++ b/nova/tests/unit/test_notifications.py @@ -52,7 +52,7 @@ class NotificationsTestCase(test.TestCase): fake_get_nw_info) fake_network.set_stub_network_methods(self) - fake_notifier.stub_notifier(self.stubs) + fake_notifier.stub_notifier(self) self.addCleanup(fake_notifier.reset) self.flags(network_manager='nova.network.manager.FlatManager',