]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Docstrings formatted according to pep257
authorSergey Skripnick <sskripnick@mirantis.com>
Tue, 30 Apr 2013 13:52:33 +0000 (16:52 +0300)
committerSergey Skripnick <sskripnick@mirantis.com>
Tue, 30 Apr 2013 13:56:35 +0000 (16:56 +0300)
Bug #1020184

quantum/tests/*

Change-Id: I5c31a70e80c7fd448b92b43d34341301533b59ba

quantum/tests/base.py
quantum/tests/unit/cisco/test_nexus_plugin.py
quantum/tests/unit/extension_stubs.py
quantum/tests/unit/hyperv/test_hyperv_quantum_agent.py
quantum/tests/unit/nicira/fake_nvpapiclient.py
quantum/tests/unit/openvswitch/test_ovs_lib.py
quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py
quantum/tests/unit/test_extensions.py
quantum/tests/unit/test_wsgi.py

index 42f48dd2887202c995e967643cb7ffb31f1d744f..9f402e36505c5bc1ecfb425f1a49f5ca36c60b9c 100644 (file)
@@ -60,8 +60,7 @@ class BaseTestCase(testtools.TestCase):
         self.stubs.Set(exception, '_FATAL_EXCEPTION_FORMAT_ERRORS', True)
 
     def config(self, **kw):
-        """
-        Override some configuration values.
+        """Override some configuration values.
 
         The keyword arguments are the names of configuration options to
         override and their values.
index 61f37e199240598a1e080acdbb1037db6d2ce81a..3e7912958a931927953e84e07ad80761a3e15860 100644 (file)
@@ -36,9 +36,7 @@ NEXUS_DRIVER = ('quantum.plugins.cisco.nexus.'
 class TestCiscoNexusPlugin(base.BaseTestCase):
 
     def setUp(self):
-        """
-        Set up function
-        """
+        """Set up function."""
         super(TestCiscoNexusPlugin, self).setUp()
         self.tenant_id = "test_tenant_cisco1"
         self.net_name = "test_network_cisco1"
@@ -84,9 +82,7 @@ class TestCiscoNexusPlugin(base.BaseTestCase):
         self.addCleanup(self.patch_obj.stop)
 
     def test_create_networks(self):
-        """
-        Tests creation of two new Virtual Networks.
-        """
+        """Tests creation of two new Virtual Networks."""
         tenant_id = self.tenant_id
         net_name = self.net_name
         net_id = self.net_id
@@ -117,9 +113,7 @@ class TestCiscoNexusPlugin(base.BaseTestCase):
         self.assertEqual(new_net_dict[const.NET_VLAN_ID], self.second_vlan_id)
 
     def test_nexus_delete_port(self):
-        """
-        Test deletion of a vlan.
-        """
+        """Test deletion of a vlan."""
         self._cisco_nexus_plugin.create_network(
             self.tenant_id, self.net_name, self.net_id, self.vlan_name,
             self.vlan_id, self._hostname, INSTANCE)
index 28ce56b7d992979fa7fbd362c4dfa8a764c0b585..57e2c7c21f280458302ce4ac8fa6f5b2a0576ad8 100644 (file)
@@ -48,9 +48,10 @@ class StubPlugin(object):
 
 
 class ExtensionExpectingPluginInterface(StubExtension):
-    """
+    """Expect plugin to implement all methods in StubPluginInterface.
+
     This extension expects plugin to implement all the methods defined
-    in StubPluginInterface
+    in StubPluginInterface.
     """
 
     def get_plugin_interface(self):
index 0b0241382f4a62e51ee4e35bcf719841a8051441..e0ef6327875590a4a2cbc13b1807380350e5d077 100644 (file)
@@ -72,7 +72,8 @@ class TestHyperVQuantumAgent(base.BaseTestCase):
         self.assertTrue(self.agent._treat_devices_added([{}]))
 
     def mock_treat_devices_added(self, details, func_name):
-        """
+        """Mock treat devices added.
+
         :param details: the details to return for the device
         :param func_name: the function that should be called
         :returns: whether the named function was called
index 6b20ab6fd1de32b31db928ce79eb3fc64f46ea89..d29d237d069a1f0616446f6179e081a3906db352 100644 (file)
@@ -291,7 +291,8 @@ class FakeClient:
         return new_data
 
     def _get_resource_type(self, path):
-        """
+        """Get resource type.
+
         Identifies resource type and relevant uuids in the uri
 
         /ws.v1/lswitch/xxx
index 74b4001b432cbb1aebe3da7027a02fd605c702a9..93bf514b2fa8257c03106f9c7578e24b59bb3b04 100644 (file)
@@ -23,8 +23,8 @@ from quantum.tests import base
 
 
 class OVS_Lib_Test(base.BaseTestCase):
-    """
-    A test suite to excercise the OVS libraries shared by Quantum agents.
+    """A test suite to excercise the OVS libraries shared by Quantum agents.
+
     Note: these tests do not actually execute ovs-* utilities, and thus
     can run on any system.  That does, however, limit their scope.
     """
@@ -41,7 +41,7 @@ class OVS_Lib_Test(base.BaseTestCase):
         self.addCleanup(self.mox.UnsetStubs)
 
     def test_vifport(self):
-        """create and stringify vif port, confirm no exceptions."""
+        """Create and stringify vif port, confirm no exceptions."""
         self.mox.ReplayAll()
 
         pname = "vif1.0"
index ce6c146de4306afb1c5b8224ba02cb3d4e58d852..cd50f874ef77f34928b6fd670fce30ec8de06199 100644 (file)
@@ -112,7 +112,7 @@ class TestOvsQuantumAgent(base.BaseTestCase):
             self.assertTrue(self.agent.treat_devices_added([{}]))
 
     def _mock_treat_devices_added(self, details, port, func_name):
-        """
+        """Mock treat devices added.
 
         :param details: the details to return for the device
         :param port: the port that get_vif_port_by_id should return
index 55c3ec93b15d16ff557b4cd93f12a4e72f8e2128..3ac43b2b6446b5ec2fb5eeb03fed008f9d5ea489 100644 (file)
@@ -426,7 +426,8 @@ class ExtensionManagerTest(base.BaseTestCase):
     def test_invalid_extensions_are_not_registered(self):
 
         class InvalidExtension(object):
-            """
+            """Invalid extension.
+
             This Extension doesn't implement extension methods :
             get_name, get_description, get_namespace and get_updated
             """
@@ -458,8 +459,8 @@ class PluginAwareExtensionManagerTest(base.BaseTestCase):
 
     def test_extensions_are_not_loaded_for_plugins_unaware_of_extensions(self):
         class ExtensionUnawarePlugin(object):
-            """
-            This plugin does not implement supports_extension method.
+            """This plugin does not implement supports_extension method.
+
             Extensions will not be loaded when this plugin is used.
             """
             pass
@@ -473,9 +474,7 @@ class PluginAwareExtensionManagerTest(base.BaseTestCase):
     def test_extensions_not_loaded_for_plugin_without_expected_interface(self):
 
         class PluginWithoutExpectedIface(object):
-            """
-            Plugin does not implement get_foo method as expected by extension
-            """
+            """Does not implement get_foo method as expected by extension."""
             supported_extension_aliases = ["supported_extension"]
 
         plugin_info = {constants.CORE: PluginWithoutExpectedIface()}
@@ -488,9 +487,7 @@ class PluginAwareExtensionManagerTest(base.BaseTestCase):
     def test_extensions_are_loaded_for_plugin_with_expected_interface(self):
 
         class PluginWithExpectedInterface(object):
-            """
-            This Plugin implements get_foo method as expected by extension
-            """
+            """Implements get_foo method as expected by extension."""
             supported_extension_aliases = ["supported_extension"]
 
             def get_foo(self, bar=None):
@@ -505,8 +502,8 @@ class PluginAwareExtensionManagerTest(base.BaseTestCase):
 
     def test_extensions_expecting_quantum_plugin_interface_are_loaded(self):
         class ExtensionForQuamtumPluginInterface(ext_stubs.StubExtension):
-            """
-            This Extension does not implement get_plugin_interface method.
+            """This Extension does not implement get_plugin_interface method.
+
             This will work with any plugin implementing QuantumPluginBase
             """
             pass
@@ -519,8 +516,8 @@ class PluginAwareExtensionManagerTest(base.BaseTestCase):
 
     def test_extensions_without_need_for__plugin_interface_are_loaded(self):
         class ExtensionWithNoNeedForPluginInterface(ext_stubs.StubExtension):
-            """
-            This Extension does not need any plugin interface.
+            """This Extension does not need any plugin interface.
+
             This will work with any plugin implementing QuantumPluginBase
             """
             def get_plugin_interface(self):
index 956a4e0c7a398cb3068a0b9ca2e0f5ba4ff2b408..c68c58b88b9fb9ac7d46a200709859b3c5ad8f98 100644 (file)
@@ -114,9 +114,7 @@ class TestWSGIServer(base.BaseTestCase):
 
 class SerializerTest(base.BaseTestCase):
     def test_serialize_unknown_content_type(self):
-        """
-        Test serialize verifies that exception InvalidContentType is raised
-        """
+        """Verify that exception InvalidContentType is raised."""
         input_dict = {'servers': {'test': 'pass'}}
         content_type = 'application/unknown'
         serializer = wsgi.Serializer()
@@ -126,10 +124,7 @@ class SerializerTest(base.BaseTestCase):
             input_dict, content_type)
 
     def test_get_deserialize_handler_unknown_content_type(self):
-        """
-        Test get deserialize verifies
-        that exception InvalidContentType is raised
-        """
+        """Verify that exception InvalidContentType is raised."""
         content_type = 'application/unknown'
         serializer = wsgi.Serializer()
 
@@ -138,9 +133,7 @@ class SerializerTest(base.BaseTestCase):
             serializer.get_deserialize_handler, content_type)
 
     def test_serialize_content_type_json(self):
-        """
-        Test serialize with content type json
-        """
+        """Test serialize with content type json."""
         input_data = {'servers': ['test=pass']}
         content_type = 'application/json'
         serializer = wsgi.Serializer(default_xmlns="fake")
@@ -149,9 +142,7 @@ class SerializerTest(base.BaseTestCase):
         self.assertEqual('{"servers": ["test=pass"]}', result)
 
     def test_serialize_content_type_xml(self):
-        """
-        Test serialize with content type xml
-        """
+        """Test serialize with content type xml."""
         input_data = {'servers': ['test=pass']}
         content_type = 'application/xml'
         serializer = wsgi.Serializer(default_xmlns="fake")
@@ -168,9 +159,7 @@ class SerializerTest(base.BaseTestCase):
         self.assertEqual(expected, result)
 
     def test_deserialize_raise_bad_request(self):
-        """
-        Test serialize verifies that exception is raises
-        """
+        """Test serialize verifies that exception is raises."""
         content_type = 'application/unknown'
         data_string = 'test'
         serializer = wsgi.Serializer(default_xmlns="fake")
@@ -180,9 +169,7 @@ class SerializerTest(base.BaseTestCase):
             serializer.deserialize, data_string, content_type)
 
     def test_deserialize_json_content_type(self):
-        """
-        Test Serializer.deserialize with content type json
-        """
+        """Test Serializer.deserialize with content type json."""
         content_type = 'application/json'
         data_string = '{"servers": ["test=pass"]}'
         serializer = wsgi.Serializer(default_xmlns="fake")
@@ -191,9 +178,7 @@ class SerializerTest(base.BaseTestCase):
         self.assertEqual({'body': {u'servers': [u'test=pass']}}, result)
 
     def test_deserialize_xml_content_type(self):
-        """
-        Test deserialize with content type xml
-        """
+        """Test deserialize with content type xml."""
         content_type = 'application/xml'
         data_string = (
             '<servers xmlns="fake">'
@@ -208,9 +193,7 @@ class SerializerTest(base.BaseTestCase):
         self.assertEqual(expected, result)
 
     def test_deserialize_xml_content_type_with_meta(self):
-        """
-        Test deserialize with content type xml with meta
-        """
+        """Test deserialize with content type xml with meta."""
         content_type = 'application/xml'
         data_string = (
             '<servers>'
@@ -229,9 +212,7 @@ class SerializerTest(base.BaseTestCase):
         self.assertEqual(expected, result)
 
     def test_serialize_xml_root_key_is_dict(self):
-        """
-        Test Serializer.serialize with content type xml with meta dict
-        """
+        """Test Serializer.serialize with content type xml with meta dict."""
         content_type = 'application/xml'
         data = {'servers': {'network': (2, 3)}}
         metadata = {'xmlns': 'fake'}
@@ -249,9 +230,7 @@ class SerializerTest(base.BaseTestCase):
         self.assertEqual(result, expected)
 
     def test_serialize_xml_root_key_is_list(self):
-        """
-        Test serialize with content type xml with meta list
-        """
+        """Test serialize with content type xml with meta list."""
         input_dict = {'servers': ['test=pass']}
         content_type = 'application/xml'
         metadata = {'application/xml': {
@@ -307,9 +286,7 @@ class RequestDeserializerTest(testtools.TestCase):
         self.deserializer = wsgi.RequestDeserializer(self.body_deserializers)
 
     def test_get_deserializer(self):
-        """
-        Test RequestDeserializer.get_body_deserializer
-        """
+        """Test RequestDeserializer.get_body_deserializer."""
         expected_json_serializer = self.deserializer.get_body_deserializer(
             'application/json')
         expected_xml_serializer = self.deserializer.get_body_deserializer(
@@ -323,9 +300,7 @@ class RequestDeserializerTest(testtools.TestCase):
             self.body_deserializers['application/xml'])
 
     def test_get_expected_content_type(self):
-        """
-        Test RequestDeserializer.get_expected_content_type
-        """
+        """Test RequestDeserializer.get_expected_content_type."""
         request = wsgi.Request.blank('/')
         request.headers['Accept'] = 'application/json'
 
@@ -334,9 +309,7 @@ class RequestDeserializerTest(testtools.TestCase):
             'application/json')
 
     def test_get_action_args(self):
-        """
-        Test RequestDeserializer.get_action_args
-        """
+        """Test RequestDeserializer.get_action_args."""
         env = {
             'wsgiorg.routing_args': [None, {
                 'controller': None,
@@ -349,9 +322,7 @@ class RequestDeserializerTest(testtools.TestCase):
             self.deserializer.get_action_args(env), expected)
 
     def test_deserialize(self):
-        """
-        Test RequestDeserializer.deserialize
-        """
+        """Test RequestDeserializer.deserialize."""
         with mock.patch.object(
             self.deserializer, 'get_action_args') as mock_method:
             mock_method.return_value = {'action': 'create'}
@@ -363,10 +334,7 @@ class RequestDeserializerTest(testtools.TestCase):
             self.assertEqual(expected, deserialized)
 
     def test_get_body_deserializer_unknown_content_type(self):
-        """
-        Test get body deserializer verifies
-         that exception InvalidContentType is raised
-        """
+        """Verify that exception InvalidContentType is raised."""
         content_type = 'application/unknown'
         deserializer = wsgi.RequestDeserializer()
         self.assertRaises(
@@ -398,28 +366,20 @@ class ResponseSerializerTest(testtools.TestCase):
             self.body_serializers, HeadersSerializer())
 
     def test_serialize_unknown_content_type(self):
-        """
-        Test serialize verifies
-        that exception InvalidContentType is raised
-        """
+        """Verify that exception InvalidContentType is raised."""
         self.assertRaises(
             exception.InvalidContentType,
             self.serializer.serialize,
             {}, 'application/unknown')
 
     def test_get_body_serializer(self):
-        """
-        Test get body serializer verifies
-        that exception InvalidContentType is raised
-        """
+        """Verify that exception InvalidContentType is raised."""
         self.assertRaises(
             exception.InvalidContentType,
             self.serializer.get_body_serializer, 'application/unknown')
 
     def test_get_serializer(self):
-        """
-        Test ResponseSerializer.get_body_serializer
-        """
+        """Test ResponseSerializer.get_body_serializer."""
         content_type = 'application/json'
         self.assertEqual(
             self.serializer.get_body_serializer(content_type),
@@ -542,9 +502,7 @@ class RequestTest(base.BaseTestCase):
 
 class ActionDispatcherTest(base.BaseTestCase):
     def test_dispatch(self):
-        """
-        Test ActionDispatcher.dispatch
-        """
+        """Test ActionDispatcher.dispatch."""
         serializer = wsgi.ActionDispatcher()
         serializer.create = lambda x: x
 
@@ -553,9 +511,7 @@ class ActionDispatcherTest(base.BaseTestCase):
             'pants')
 
     def test_dispatch_action_None(self):
-        """
-        Test ActionDispatcher.dispatch with none action
-        """
+        """Test ActionDispatcher.dispatch with none action."""
         serializer = wsgi.ActionDispatcher()
         serializer.create = lambda x: x + ' pants'
         serializer.default = lambda x: x + ' trousers'
@@ -662,9 +618,10 @@ class JSONDeserializerTest(base.BaseTestCase):
             deserializer.deserialize(data), as_dict)
 
     def test_default_raise_Malformed_Exception(self):
-        """
-        Test verifies JsonDeserializer.default
-        raises exception MalformedRequestBody correctly
+        """Test JsonDeserializer.default.
+
+        Test verifies JsonDeserializer.default raises exception
+        MalformedRequestBody correctly.
         """
         data_string = ""
         deserializer = wsgi.JSONDeserializer()
@@ -704,9 +661,7 @@ class XMLDeserializerTest(base.BaseTestCase):
             {'body': {u'a': {u'b': u'test'}}}, deserializer(xml))
 
     def test_default_raise_Malformed_Exception(self):
-        """
-        Test verifies that exception MalformedRequestBody is raised
-        """
+        """Verify that exception MalformedRequestBody is raised."""
         data_string = ""
         deserializer = wsgi.XMLDeserializer()