]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Completes coverage of quantum.agent.rpc.py
authorZhongyue Luo <zhongyue.nah@intel.com>
Thu, 29 Nov 2012 03:29:07 +0000 (11:29 +0800)
committerZhongyue Luo <zhongyue.nah@intel.com>
Thu, 29 Nov 2012 05:37:46 +0000 (13:37 +0800)
Added test cases

Fixes bug #1084381

Change-Id: I9179aac206befa6b0449814646639ed96a1eadbc

quantum/agent/rpc.py
quantum/tests/unit/test_agent_rpc.py

index cab2c2ae2bb6599c7f7a133d0b70d3bfb8604074..dc65175c8888e0e747e44fcade5b72cafd8713a6 100644 (file)
@@ -1,17 +1,19 @@
-# Copyright (c) 2012 OpenStack, LLC.
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (c) 2012 OpenStack LLC.
+# All Rights Reserved.
 #
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
 #
-#    http://www.apache.org/licenses/LICENSE-2.0
+#         http://www.apache.org/licenses/LICENSE-2.0
 #
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
 
 import eventlet
 
index 8dae30bf14cb4bde104f072263edd4a2e8bf70e8..a36ea0d89fbeed0ac36fa8d2cc54f9af1f1589b3 100644 (file)
@@ -1,6 +1,6 @@
 # vim: tabstop=4 shiftwidth=4 softtabstop=4
 
-# Copyright 2012 OpenStack LLC
+# Copyright (c) 2012 OpenStack LLC.
 # All Rights Reserved.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -21,6 +21,31 @@ import mock
 
 from quantum.agent import rpc
 from quantum.openstack.common import cfg
+from quantum.openstack.common import context
+
+
+class AgentRPCPluginApi(unittest.TestCase):
+    def _test_rpc_call(self, method):
+        agent = rpc.PluginApi('fake_topic')
+        ctxt = context.RequestContext('fake_user', 'fake_project')
+        expect_val = 'foo'
+        with mock.patch('quantum.openstack.common.rpc.call') as rpc_call:
+            rpc_call.return_value = expect_val
+            func_obj = getattr(agent, method)
+            if method == 'tunnel_sync':
+                actual_val = func_obj(ctxt, 'fake_tunnel_ip')
+            else:
+                actual_val = func_obj(ctxt, 'fake_device', 'fake_agent_id')
+        self.assertEqual(actual_val, expect_val)
+
+    def test_get_device_details(self):
+        self._test_rpc_call('get_device_details')
+
+    def test_update_device_down(self):
+        self._test_rpc_call('update_device_down')
+
+    def test_tunnel_sync(self):
+        self._test_rpc_call('tunnel_sync')
 
 
 class AgentRPCMethods(unittest.TestCase):