]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Mocking ryu plugin notifier in ryu plugin test
authorAkihiro Motoki <motoki@da.jp.nec.com>
Wed, 27 Nov 2013 10:09:01 +0000 (19:09 +0900)
committerAkihiro Motoki <motoki@da.jp.nec.com>
Wed, 27 Nov 2013 12:02:23 +0000 (21:02 +0900)
Previously RPC notifier is not mocked in ryu plugin test and the
plugin tries to send RPC notifications. It may interact with
impl_fake RPC set up in previous tests by other plugin
and sometimes leads to unexpected ovs-vsctl invoking.

Change-Id: I11714a160faa4d3ded7f312c39afba0b426ccd8a
Closes-Bug: #1255421

neutron/tests/unit/ryu/test_ryu_plugin.py

index 3bb854f98a4708a06081111c9a00df30153118d2..e0dfe283eecdabf97619258da935f1ef15f09f8f 100644 (file)
@@ -13,6 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import mock
+
+from neutron import manager
 from neutron.plugins.ryu.db import models_v2 as ryu_models_v2  # noqa
 from neutron.tests.unit.ryu import fake_ryu
 from neutron.tests.unit import test_db_plugin as test_plugin
@@ -27,6 +30,8 @@ class RyuPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
         self.ryu_patcher.start()
         super(RyuPluginV2TestCase, self).setUp(self._plugin_name)
         self.addCleanup(self.ryu_patcher.stop)
+        plugin = manager.NeutronManager.get_plugin()
+        plugin.notifier = mock.Mock()
 
 
 class TestRyuBasicGet(test_plugin.TestBasicGet, RyuPluginV2TestCase):