From: Sergey Skripnick Date: Tue, 30 Apr 2013 13:52:33 +0000 (+0300) Subject: Docstrings formatted according to pep257 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=13fbf22ff43512936eff8733457b69546fd4c70d;p=openstack-build%2Fneutron-build.git Docstrings formatted according to pep257 Bug #1020184 quantum/tests/* Change-Id: I5c31a70e80c7fd448b92b43d34341301533b59ba --- diff --git a/quantum/tests/base.py b/quantum/tests/base.py index 42f48dd28..9f402e365 100644 --- a/quantum/tests/base.py +++ b/quantum/tests/base.py @@ -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. diff --git a/quantum/tests/unit/cisco/test_nexus_plugin.py b/quantum/tests/unit/cisco/test_nexus_plugin.py index 61f37e199..3e7912958 100644 --- a/quantum/tests/unit/cisco/test_nexus_plugin.py +++ b/quantum/tests/unit/cisco/test_nexus_plugin.py @@ -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) diff --git a/quantum/tests/unit/extension_stubs.py b/quantum/tests/unit/extension_stubs.py index 28ce56b7d..57e2c7c21 100644 --- a/quantum/tests/unit/extension_stubs.py +++ b/quantum/tests/unit/extension_stubs.py @@ -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): diff --git a/quantum/tests/unit/hyperv/test_hyperv_quantum_agent.py b/quantum/tests/unit/hyperv/test_hyperv_quantum_agent.py index 0b0241382..e0ef63278 100644 --- a/quantum/tests/unit/hyperv/test_hyperv_quantum_agent.py +++ b/quantum/tests/unit/hyperv/test_hyperv_quantum_agent.py @@ -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 diff --git a/quantum/tests/unit/nicira/fake_nvpapiclient.py b/quantum/tests/unit/nicira/fake_nvpapiclient.py index 6b20ab6fd..d29d237d0 100644 --- a/quantum/tests/unit/nicira/fake_nvpapiclient.py +++ b/quantum/tests/unit/nicira/fake_nvpapiclient.py @@ -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 diff --git a/quantum/tests/unit/openvswitch/test_ovs_lib.py b/quantum/tests/unit/openvswitch/test_ovs_lib.py index 74b4001b4..93bf514b2 100644 --- a/quantum/tests/unit/openvswitch/test_ovs_lib.py +++ b/quantum/tests/unit/openvswitch/test_ovs_lib.py @@ -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" diff --git a/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py b/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py index ce6c146de..cd50f874e 100644 --- a/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py +++ b/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py @@ -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 diff --git a/quantum/tests/unit/test_extensions.py b/quantum/tests/unit/test_extensions.py index 55c3ec93b..3ac43b2b6 100644 --- a/quantum/tests/unit/test_extensions.py +++ b/quantum/tests/unit/test_extensions.py @@ -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): diff --git a/quantum/tests/unit/test_wsgi.py b/quantum/tests/unit/test_wsgi.py index 956a4e0c7..c68c58b88 100644 --- a/quantum/tests/unit/test_wsgi.py +++ b/quantum/tests/unit/test_wsgi.py @@ -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 = ( '' @@ -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 = ( '' @@ -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()