Docstrings formatted according to pep257

Bug #1020184

quantum/tests/*

Change-Id: I5c31a70e80c7fd448b92b43d34341301533b59ba
This commit is contained in:
Sergey Skripnick 2013-04-30 16:52:33 +03:00
parent 58d13eb351
commit 13fbf22ff4
9 changed files with 50 additions and 102 deletions

View 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.

View 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)

View 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):

View 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

View 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

View 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"

View 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

View 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):

View 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()