]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Completes coverage of quantum.agent.netns_cleanup.py
authorZhongyue Luo <zhongyue.nah@intel.com>
Thu, 29 Nov 2012 01:37:24 +0000 (09:37 +0800)
committerZhongyue Luo <zhongyue.nah@intel.com>
Thu, 29 Nov 2012 05:10:01 +0000 (13:10 +0800)
Added test cases
Fixed typos

Fixes bug #1084332

Change-Id: I86c2321dfe5f3f1ac4b8b570a6c76dbb1928bfb0

quantum/agent/netns_cleanup_util.py
quantum/tests/unit/test_agent_netns_cleanup.py

index 7271968b3c0ed00ddc1d266d3e8357e4bafabb74..f3b0b6fc38bba58ff677eacdf089b2f90dca9ce6 100644 (file)
@@ -1,3 +1,20 @@
+# 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
+#
+#         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.
+
 import re
 import sys
 
@@ -14,6 +31,7 @@ from quantum.openstack.common import cfg
 from quantum.openstack.common import importutils
 from quantum.openstack.common import log as logging
 
+
 LOG = logging.getLogger(__name__)
 NS_MANGLING_PATTERN = ('(%s|%s)' % (dhcp_agent.NS_PREFIX, l3_agent.NS_PREFIX) +
                        attributes.UUID_PATTERN)
index 557b771b96c4b538359af28517774b92571b8134..5cddbbd30e2e73ba3de68f972d62fe7c0ded48b4 100644 (file)
@@ -1,9 +1,32 @@
+# 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
+#
+#         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.
+
 import mock
 import unittest2 as unittest
 
 from quantum.agent import netns_cleanup_util as util
 
 
+class TestNullDelegate(unittest.TestCase):
+    def test_getattribute(self):
+        null_delegate = util.NullDelegate()
+        self.assertIsNone(null_delegate.test())
+
+
 class TestNetnsCleanup(unittest.TestCase):
     def test_setup_conf(self):
         with mock.patch('quantum.common.config.setup_logging'):
@@ -159,15 +182,23 @@ class TestNetnsCleanup(unittest.TestCase):
                     expected.append(mock.call().garbage_collect_namespace())
                     ip_wrap.assert_has_calls(expected)
 
-    def test_destory_namespace_empty(self):
+    def test_destroy_namespace_empty(self):
         self._test_destroy_namespace_helper(False, 0)
 
-    def test_destory_namespace_not_empty(self):
+    def test_destroy_namespace_not_empty(self):
         self._test_destroy_namespace_helper(False, 1)
 
-    def test_destory_namespace_not_empty_forced(self):
+    def test_destroy_namespace_not_empty_forced(self):
         self._test_destroy_namespace_helper(True, 2)
 
+    def test_destroy_namespace_exception(self):
+        ns = 'qrouter-6e322ac7-ab50-4f53-9cdc-d1d3c1164b6d'
+        conf = mock.Mock()
+        conf.root_helper = 'sudo'
+        with mock.patch('quantum.agent.linux.ip_lib.IPWrapper') as ip_wrap:
+            ip_wrap.side_effect = Exception()
+            util.destroy_namespace(conf, ns)
+
     def test_main(self):
         namespaces = ['ns1', 'ns2']
         with mock.patch('quantum.agent.linux.ip_lib.IPWrapper') as ip_wrap: