Fix [H405] pep rule in heat/tests

Implements bp docstring-improvements

Change-Id: I2fd82d698f42aca3b34822875cf4d706fedbf5f2
changes/81/227381/5
Peter Razumovsky 7 years ago
parent 34f32eef0e
commit c4b0ced813
  1. 5
      heat/tests/api/aws/test_api_aws.py
  2. 4
      heat/tests/api/aws/test_api_ec2token.py
  3. 3
      heat/tests/api/cfn/test_api_cfn_v1.py
  4. 5
      heat/tests/api/cloudwatch/test_api_cloudwatch.py
  5. 5
      heat/tests/api/openstack_v1/test_actions.py
  6. 5
      heat/tests/api/openstack_v1/test_events.py
  7. 5
      heat/tests/api/openstack_v1/test_resources.py
  8. 5
      heat/tests/api/openstack_v1/test_stacks.py
  9. 7
      heat/tests/api/openstack_v1/tools.py
  10. 4
      heat/tests/autoscaling/test_heat_scaling_group.py
  11. 15
      heat/tests/autoscaling/test_scaling_template.py
  12. 37
      heat/tests/aws/test_instance.py
  13. 17
      heat/tests/ceilometer/test_ceilometer_alarm.py
  14. 6
      heat/tests/clients/test_cinder_client.py
  15. 5
      heat/tests/clients/test_glance_client.py
  16. 17
      heat/tests/clients/test_heat_client.py
  17. 9
      heat/tests/clients/test_nova_client.py
  18. 5
      heat/tests/clients/test_sahara_client.py
  19. 12
      heat/tests/convergence/framework/engine_wrapper.py
  20. 22
      heat/tests/convergence/framework/message_processor.py
  21. 14
      heat/tests/engine/service/test_stack_update.py
  22. 5
      heat/tests/engine/tools.py
  23. 11
      heat/tests/fakes.py
  24. 4
      heat/tests/generic_resource.py
  25. 21
      heat/tests/nova/test_server.py
  26. 7
      heat/tests/openstack/monasca/test_alarm_definition.py
  27. 7
      heat/tests/openstack/monasca/test_notification.py
  28. 16
      heat/tests/test_common_context.py
  29. 22
      heat/tests/test_constraints.py
  30. 1
      heat/tests/test_convg_stack.py
  31. 12
      heat/tests/test_cw_alarm.py
  32. 9
      heat/tests/test_dbinstance.py
  33. 4
      heat/tests/test_engine_api_utils.py
  34. 13
      heat/tests/test_engine_service.py
  35. 12
      heat/tests/test_engine_service_stack_watch.py
  36. 16
      heat/tests/test_environment.py
  37. 37
      heat/tests/test_hot.py
  38. 41
      heat/tests/test_lifecycle_plugin_utils.py
  39. 15
      heat/tests/test_metadata_refresh.py
  40. 6
      heat/tests/test_provider_template.py
  41. 32
      heat/tests/test_resource.py
  42. 34
      heat/tests/test_resource_group.py
  43. 3
      heat/tests/test_rpc_client.py
  44. 3
      heat/tests/test_software_deployment.py
  45. 44
      heat/tests/test_stack.py
  46. 28
      heat/tests/test_stack_resource.py
  47. 71
      heat/tests/test_stack_update.py
  48. 3
      heat/tests/test_structured_config.py
  49. 6
      heat/tests/test_swift.py

@ -18,9 +18,8 @@ from heat.tests import common
class AWSCommonTest(common.HeatTestCase):
'''
Tests the api/aws common components
'''
"""Tests the api/aws common components."""
# The tests
def test_format_response(self):
response = api_utils.format_response("Foo", "Bar")

@ -28,9 +28,7 @@ from heat.tests import utils
class Ec2TokenTest(common.HeatTestCase):
"""
Tests the Ec2Token middleware
"""
"""Tests the Ec2Token middleware."""
def setUp(self):
super(Ec2TokenTest, self).setUp()

@ -33,7 +33,8 @@ policy_path = os.path.dirname(os.path.realpath(__file__)) + "/../../policy/"
class CfnStackControllerTest(common.HeatTestCase):
"""
"""Tests the API class CfnStackController.
Tests the API class which acts as the WSGI controller,
the endpoint processing API requests after they are routed
"""

@ -27,10 +27,11 @@ from heat.tests import utils
class WatchControllerTest(common.HeatTestCase):
'''
"""Tests the API class WatchController.
Tests the API class which acts as the WSGI controller,
the endpoint processing API requests after they are routed
'''
"""
def setUp(self):
super(WatchControllerTest, self).setUp()

@ -28,10 +28,11 @@ from heat.tests import common
@mock.patch.object(policy.Enforcer, 'enforce')
class ActionControllerTest(tools.ControllerTest, common.HeatTestCase):
'''
"""Tests the API class ActionController.
Tests the API class which acts as the WSGI controller,
the endpoint processing API requests after they are routed
'''
"""
def setUp(self):
super(ActionControllerTest, self).setUp()

@ -27,10 +27,11 @@ from heat.tests import common
@mock.patch.object(policy.Enforcer, 'enforce')
class EventControllerTest(tools.ControllerTest, common.HeatTestCase):
'''
"""Tests the API class EventController.
Tests the API class which acts as the WSGI controller,
the endpoint processing API requests after they are routed
'''
"""
def setUp(self):
super(EventControllerTest, self).setUp()

@ -28,10 +28,11 @@ from heat.tests import common
@mock.patch.object(policy.Enforcer, 'enforce')
class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase):
'''
"""Tests the API class ResourceController.
Tests the API class which acts as the WSGI controller,
the endpoint processing API requests after they are routed
'''
"""
def setUp(self):
super(ResourceControllerTest, self).setUp()

@ -201,10 +201,11 @@ blarg: wibble
@mock.patch.object(policy.Enforcer, 'enforce')
class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
'''
"""Tests the API class StackController.
Tests the API class which acts as the WSGI controller,
the endpoint processing API requests after they are routed
'''
"""
def setUp(self):
super(StackControllerTest, self).setUp()

@ -33,8 +33,7 @@ def request_with_middleware(middleware, func, req, *args, **kwargs):
def to_remote_error(error):
"""Converts the given exception to the one with the _Remote suffix.
"""
"""Converts the given exception to the one with the _Remote suffix."""
exc_info = (type(error), error, None)
serialized = rpc_common.serialize_remote_exception(exc_info)
remote_error = rpc_common.deserialize_remote_exception(
@ -43,9 +42,7 @@ def to_remote_error(error):
class ControllerTest(object):
"""
Common utilities for testing API Controllers.
"""
"""Common utilities for testing API Controllers."""
def __init__(self, *args, **kwargs):
super(ControllerTest, self).__init__(*args, **kwargs)

@ -397,7 +397,9 @@ class HeatScalingGroupAttrTest(common.HeatTestCase):
self.assertIsNone(self.group.validate())
def test_no_instance_list(self):
"""The InstanceList attribute is not inherited from
"""Tests inheritance of InstanceList attribute.
The InstanceList attribute is not inherited from
AutoScalingResourceGroup's superclasses.
"""
self.assertRaises(exception.InvalidTemplateAttribute,

@ -25,7 +25,8 @@ class ResourceTemplatesTest(common.HeatTestCase):
self.next_id = lambda: next(ids)
def test_create_template(self):
"""
"""Test case for creating template.
When creating a template from scratch, an empty list is accepted as
the "old" resources and new resources are created up to num_resource.
"""
@ -37,7 +38,8 @@ class ResourceTemplatesTest(common.HeatTestCase):
self.assertEqual(expected, list(templates))
def test_replace_template(self):
"""
"""Test case for replacing template.
If num_replace is the number of old resources, then all of the
resources will be replaced.
"""
@ -50,7 +52,8 @@ class ResourceTemplatesTest(common.HeatTestCase):
self.assertEqual(expected, list(templates))
def test_replace_some_units(self):
"""
"""Test case for making only the number of replacements specified.
If the resource definition changes, only the number of replacements
specified will be made; beyond that, the original templates are used.
"""
@ -66,7 +69,8 @@ class ResourceTemplatesTest(common.HeatTestCase):
self.assertEqual(expected, list(templates))
def test_growth_counts_as_replacement(self):
"""
"""Test case for growing template.
If we grow the template and replace some elements at the same time, the
number of replacements to perform is reduced by the number of new
resources to be created.
@ -86,7 +90,8 @@ class ResourceTemplatesTest(common.HeatTestCase):
self.assertEqual(expected, list(templates))
def test_replace_units_some_already_up_to_date(self):
"""
"""Test case for up-to-date resources in template.
If some of the old resources already have the new resource definition,
then they won't be considered for replacement, and the next resource
that is out-of-date will be replaced.

@ -714,7 +714,8 @@ class InstancesTest(common.HeatTestCase):
self.assertEqual({'test': 123}, instance.metadata_get())
def test_instance_update_instance_type(self):
"""
"""Test case for updating InstanceType.
Instance.handle_update supports changing the InstanceType, and makes
the change making a resize API call against Nova.
"""
@ -761,7 +762,8 @@ class InstancesTest(common.HeatTestCase):
self.m.VerifyAll()
def test_instance_update_instance_type_failed(self):
"""
"""Test case for raising exception due to resize call failed.
If the status after a resize is not VERIFY_RESIZE, it means the resize
call failed, so we raise an explicit error.
"""
@ -812,7 +814,8 @@ class InstancesTest(common.HeatTestCase):
return fake_interface(port, net, ip)
def test_instance_update_network_interfaces(self):
"""
"""Test case for updating NetworkInterfaces.
Instance.handle_update supports changing the NetworkInterfaces,
and makes the change making a resize API call against Nova.
"""
@ -853,7 +856,8 @@ class InstancesTest(common.HeatTestCase):
self.m.VerifyAll()
def test_instance_update_network_interfaces_old_include_new(self):
"""
"""Test case for updating NetworkInterfaces when old prop includes new.
Instance.handle_update supports changing the NetworkInterfaces,
and makes the change making a resize API call against Nova.
"""
@ -888,7 +892,8 @@ class InstancesTest(common.HeatTestCase):
self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)
def test_instance_update_network_interfaces_new_include_old(self):
"""
"""Test case for updating NetworkInterfaces when new prop includes old.
Instance.handle_update supports changing the NetworkInterfaces,
and makes the change making a resize API call against Nova.
"""
@ -923,7 +928,8 @@ class InstancesTest(common.HeatTestCase):
self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)
def test_instance_update_network_interfaces_new_old_all_different(self):
"""
"""Tests updating NetworkInterfaces when new and old are different.
Instance.handle_update supports changing the NetworkInterfaces,
and makes the change making a resize API call against Nova.
"""
@ -963,7 +969,8 @@ class InstancesTest(common.HeatTestCase):
self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)
def test_instance_update_network_interfaces_no_old(self):
"""
"""Test case for updating NetworkInterfaces when there's no old prop.
Instance.handle_update supports changing the NetworkInterfaces,
and makes the change making a resize API call against Nova.
"""
@ -1004,8 +1011,9 @@ class InstancesTest(common.HeatTestCase):
self.m.VerifyAll()
def test_instance_update_network_interfaces_no_old_empty_new(self):
"""
Instance.handle_update supports changing the NetworkInterfaces
"""Test case for updating NetworkInterfaces when no old, no new prop.
Instance.handle_update supports changing the NetworkInterfaces.
"""
return_server = self.fc.servers.list()[1]
return_server.id = '1234'
@ -1083,9 +1091,7 @@ class InstancesTest(common.HeatTestCase):
self.m.VerifyAll()
def test_instance_update_network_interfaces_empty_new_with_subnet(self):
"""
Test update NetworkInterfaces to empty, and update with subnet.
"""
"""Test update NetworkInterfaces to empty, and update with subnet."""
stack_name = 'ud_network_interfaces_empty_with_subnet'
self._test_instance_update_with_subnet(
stack_name, new_interfaces=[])
@ -1334,9 +1340,10 @@ class InstancesTest(common.HeatTestCase):
))
def test_build_nics_with_security_groups(self):
"""
Test the security groups defined in heat template can be associated
to a new created port.
"""Test the security groups can be associated to a new created port.
Test the security groups defined in heat template can be associated to
a new created port.
"""
return_server = self.fc.servers.list()[1]
instance = self._create_test_instance(return_server,

@ -205,10 +205,8 @@ class CeilometerAlarmTest(common.HeatTestCase):
return stack
def test_mem_alarm_high_update_no_replace(self):
'''
Make sure that we can change the update-able properties
without replacing the Alarm rsrc.
'''
"""Tests update updatable properties without replacing the Alarm."""
# short circuit the alarm's references
t = template_format.parse(alarm_template)
properties = t['Resources']['MEMAlarmHigh']['Properties']
@ -270,10 +268,8 @@ class CeilometerAlarmTest(common.HeatTestCase):
self.m.VerifyAll()
def test_mem_alarm_high_update_replace(self):
'''
Make sure that the Alarm resource IS replaced when non-update-able
properties are changed.
'''
"""Tests resource replacing when changing non-updatable properties."""
t = template_format.parse(alarm_template)
properties = t['Resources']['MEMAlarmHigh']['Properties']
properties['alarm_actions'] = ['signal_handler']
@ -297,9 +293,10 @@ class CeilometerAlarmTest(common.HeatTestCase):
self.m.VerifyAll()
def test_mem_alarm_suspend_resume(self):
"""
"""Tests suspending and resuming of the alarm.
Make sure that the Alarm resource gets disabled on suspend
and reenabled on resume.
and re-enabled on resume.
"""
self.stack = self.create_stack()

@ -23,10 +23,8 @@ from heat.tests import utils
class CinderClientPluginTests(common.HeatTestCase):
"""
Basic tests for the helper methods in
:module:'heat.engine.clients.os.cinder'.
"""
"""Basic tests for :module:'heat.engine.clients.os.cinder'."""
def setUp(self):
super(CinderClientPluginTests, self).setUp()
self.cinder_client = mock.MagicMock()

@ -24,10 +24,7 @@ from heat.tests import utils
class GlanceUtilsTests(common.HeatTestCase):
"""
Basic tests for the helper methods in
:module:'heat.engine.resources.clients.os.glance'.
"""
"""Basic tests for :module:'heat.engine.resources.clients.os.glance'."""
def setUp(self):
super(GlanceUtilsTests, self).setUp()

@ -1372,10 +1372,7 @@ class KeystoneClientTest(common.HeatTestCase):
project_id='aprojectid'))
def _test_url_for(self, service_url, expected_kwargs, ctx=None, **kwargs):
"""
Helper function for testing url_for depending on different ways to
pass region name.
"""
"""Testing url_for depending on different ways to pass region name."""
mock_ks_auth, mock_auth_ref = self._stubs_v3(client=False)
mock_ks_auth.get_endpoint(mox.IsA(ks_session.Session),
**expected_kwargs).AndReturn(service_url)
@ -1387,7 +1384,8 @@ class KeystoneClientTest(common.HeatTestCase):
self.m.VerifyAll()
def test_url_for(self):
"""
"""Test that None value is passed as region name.
Test that None value is passed as region name if region name is not
specified in the config file or as one of the arguments.
"""
@ -1399,7 +1397,8 @@ class KeystoneClientTest(common.HeatTestCase):
self._test_url_for(service_url, kwargs)
def test_url_for_with_region(self):
"""
"""Test that region name passed as argument.
Test that region name passed as argument is not override by region name
specified in the config file.
"""
@ -1411,7 +1410,8 @@ class KeystoneClientTest(common.HeatTestCase):
self._test_url_for(service_url, kwargs, None, **kwargs)
def test_url_for_with_region_name_from_config(self):
"""
"""Test default region name for services from config file is passed.
Test that default region name for services from config file is passed
if region name is not specified in arguments.
"""
@ -1425,7 +1425,8 @@ class KeystoneClientTest(common.HeatTestCase):
self._test_url_for(service_url, kwargs)
def test_url_for_with_region_name_from_context(self):
"""
"""Test that default region name for services from context is passed.
Test that default region name for services from context is passed
if region name is not specified in arguments.
"""

@ -40,10 +40,7 @@ class NovaClientPluginTestCase(common.HeatTestCase):
class NovaClientPluginTests(NovaClientPluginTestCase):
"""
Basic tests for the helper methods in
:module:'heat.engine.clients.os.nova'.
"""
"""Basic tests for :module:'heat.engine.clients.os.nova'."""
def test_create(self):
context = utils.dummy_context()
@ -393,9 +390,7 @@ class NovaClientPluginMetadataTests(NovaClientPluginTestCase):
self.assertEqual(expected, self.nova_plugin.meta_serialize(original))
def test_serialize_no_value(self):
"""This test is to prove that the user can only pass in a dict to nova
metadata.
"""
"""Prove that the user can only pass in a dict to nova metadata."""
excp = self.assertRaises(exception.StackValidationFailed,
self.nova_plugin.meta_serialize, "foo")
self.assertIn('metadata needs to be a Map', six.text_type(excp))

@ -24,10 +24,7 @@ from heat.tests import utils
class SaharaUtilsTests(common.HeatTestCase):
"""
Basic tests for the helper methods in
:module:'heat.engine.resources.clients.os.sahara'.
"""
"""Basic tests :module:'heat.engine.resources.clients.os.sahara'."""
def setUp(self):
super(SaharaUtilsTests, self).setUp()

@ -23,10 +23,10 @@ from heat.tests import utils
class Engine(message_processor.MessageProcessor):
'''
Wrapper to the engine service. Methods of this
class will be called from the scenario tests.
'''
"""Wrapper to the engine service.
Methods of this class will be called from the scenario tests.
"""
queue = message_queue.MessageQueue('engine')
@ -34,9 +34,7 @@ class Engine(message_processor.MessageProcessor):
super(Engine, self).__init__('engine')
def scenario_template_to_hot(self, scenario_tmpl):
'''
Converts the scenario template into hot template.
'''
"""Converts the scenario template into hot template."""
hot_tmpl = {"heat_template_version": "2013-05-23"}
resources = {}
for res_name, res_def in six.iteritems(scenario_tmpl.resources):

@ -21,12 +21,13 @@ LOG = logging.getLogger(__name__)
def asynchronous(function):
'''Decorator for MessageProcessor methods to make them asynchronous.
"""Decorator for MessageProcessor methods to make them asynchronous.
To use, simply call the method as usual. Instead of being executed
immediately, it will be placed on the queue for the MessageProcessor and
run on a future iteration of the event loop.
'''
"""
arg_names = inspect.getargspec(function).args
MessageData = collections.namedtuple(function.__name__, arg_names[1:])
@ -76,9 +77,7 @@ class MessageProcessor(object):
@asynchronous
def noop(self, count=1):
'''
Insert <count> No-op operations in the message queue.
'''
"""Insert <count> No-op operations in the message queue."""
assert isinstance(count, int)
if count > 1:
self.queue.send_priority('noop',
@ -86,24 +85,19 @@ class MessageProcessor(object):
@asynchronous
def _execute(self, func):
'''
Insert a function call in the message queue.
"""Insert a function call in the message queue.
The function takes no arguments, so use functools.partial to curry the
arguments before passing it here.
'''
"""
func()
def call(self, func, *args, **kwargs):
'''
Insert a function call in the message queue.
'''
"""Insert a function call in the message queue."""
self._execute(functools.partial(func, *args, **kwargs))
def clear(self):
'''
Delete all the messages from the queue.
'''
"""Delete all the messages from the queue."""
self.queue.clear()
__all__ = ['MessageProcessor', 'asynchronous']

@ -127,10 +127,12 @@ class ServiceStackUpdateTest(common.HeatTestCase):
self.assertEqual(stk.identifier(), result)
def test_stack_update_existing_parameters_remove(self):
'''Use a template with existing parameters, then update with a
"""Test case for updating stack with changed parameters.
Use a template with existing parameters, then update with a
template containing additional parameters and a list of
parameters to be removed.
'''
"""
stack_name = 'service_update_test_stack_existing_parameters_remove'
update_params = {'encrypted_param_names': [],
'parameter_defaults': {},
@ -227,9 +229,11 @@ class ServiceStackUpdateTest(common.HeatTestCase):
self.assertEqual(stk.identifier(), result)
def test_stack_update_existing_parameter_defaults(self):
'''Use a template with existing flag and ensure the
environment parameter_defaults are preserved.
'''
"""Ensure the environment parameter_defaults are preserved.
Use a template with existing flag and ensure the environment
parameter_defaults are preserved.
"""
stack_name = 'service_update_test_stack_existing_param_defaults'
intial_params = {'encrypted_param_names': [],
'parameter_defaults': {'mydefault': 123},

@ -250,10 +250,11 @@ def clean_up_stack(stack, delete_res=True):
def stack_context(stack_name, create_res=True):
"""
"""Decorator for creating and deleting stack.
Decorator which creates a stack by using the test case's context and
deletes it afterwards to ensure tests clean up their stacks regardless
of test success/failure
of test success/failure.
"""
def stack_delete(test_fn):
@six.wraps(test_fn)

@ -11,8 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
"""
A fake server that "responds" to API methods with pre-canned responses.
"""A fake server that "responds" to API methods with pre-canned responses.
All of these responses come from the spec, so if for some reason the spec's
wrong the tests might raise AssertionError. I've indicated in comments the
@ -28,9 +27,7 @@ from heat.common import context
class FakeClient(object):
def assert_called(self, method, url, body=None, pos=-1):
"""
Assert than an API method was just called.
"""
"""Assert that an API method was just called."""
expected = (method, url)
called = self.client.callstack[pos][0:2]
@ -44,9 +41,7 @@ class FakeClient(object):
assert self.client.callstack[pos][2] == body
def assert_called_anytime(self, method, url, body=None):
"""
Assert than an API method was called anytime in the test.
"""
"""Assert that an API method was called anytime in the test."""
expected = (method, url)
assert self.client.callstack, ("Expected %s %s but no calls "

@ -28,9 +28,7 @@ LOG = logging.getLogger(__name__)
class GenericResource(resource.Resource):
'''
Dummy resource for use in tests
'''
"""Dummy resource for use in tests."""
properties_schema = {}
attributes_schema = collections.OrderedDict([
('foo', attributes.Schema('A generic attribute')),

@ -1646,9 +1646,10 @@ class ServersTest(common.HeatTestCase):
self.m.VerifyAll()
def test_server_update_nova_metadata_complex(self):
"""
Test that complex metadata values are correctly serialized
to JSON when sent to Nova.
"""Test that complex metadata values are correctly serialized to JSON.
Test that complex metadata values are correctly serialized to JSON when
sent to Nova.
"""
return_server = self.fc.servers.list()[1]
@ -1720,9 +1721,7 @@ class ServersTest(common.HeatTestCase):
self.m.VerifyAll()
def test_server_update_server_name(self):
"""
Server.handle_update supports changing the name.
"""
"""Server.handle_update supports changing the name."""
return_server = self.fc.servers.list()[1]
return_server.id = '5678'
server = self._create_test_server(return_server,
@ -1743,9 +1742,7 @@ class ServersTest(common.HeatTestCase):
self.m.VerifyAll()
def test_server_update_server_admin_password(self):
"""
Server.handle_update supports changing the admin password.
"""
"""Server.handle_update supports changing the admin password."""
return_server = self.fc.servers.list()[1]
return_server.id = '5678'
server = self._create_test_server(return_server,
@ -1764,7 +1761,8 @@ class ServersTest(common.HeatTestCase):
self.assertEqual(1, return_server.change_password.call_count)
def test_server_update_server_flavor(self):
"""
"""Tests update server changing the flavor.
Server.handle_update supports changing the flavor, and makes
the change making a resize API call against Nova.
"""
@ -1811,7 +1809,8 @@ class ServersTest(common.HeatTestCase):
self.m.VerifyAll()
def test_server_update_server_flavor_failed(self):
"""
"""Check raising exception due to resize call failing.
If the status after a resize is not VERIFY_RESIZE, it means the resize
call failed, so we raise an explicit error.
"""

@ -46,10 +46,11 @@ RESOURCE_TYPE = 'OS::Monasca::AlarmDefinition'
class MonascaAlarmDefinition(alarm_definition.MonascaAlarmDefinition):
'''
"""This class overrides the is_service_available to return True.
Monasca service is not available by default. So, this class overrides
the is_service_available to return True
'''
the is_service_available to return True.
"""
@classmethod
def is_service_available(cls, context):
return True

@ -40,10 +40,11 @@ RESOURCE_TYPE = 'OS::Monasca::Notification'
class MonascaNotification(notification.MonascaNotification):
'''
"""This class overrides the is_service_available to return True.
Monasca service is not available by default. So, this class overrides
the is_service_available to return True
'''
the is_service_available to return True.
"""
@classmethod
def is_service_available(cls, context):
return True

@ -114,9 +114,7 @@ class TestRequestContext(common.HeatTestCase):
self.assertFalse(ctx.is_admin)
def test_keystone_v3_endpoint_in_context(self):
"""Ensure that the context is the preferred source for the
auth_uri.
"""
"""Ensure that the context is the preferred source for the auth_uri."""
cfg.CONF.set_override('auth_uri', 'http://xyz',
group='clients_keystone')
policy_check = 'heat.common.policy.Enforcer.check_is_admin'
@ -128,7 +126,9 @@ class TestRequestContext(common.HeatTestCase):
'http://example.com:5000/v3')
def test_keystone_v3_endpoint_in_clients_keystone_config(self):
"""Ensure that the [clients_keystone] section of the configuration is
"""Ensure that the [clients_keystone] section is the preferred source.
Ensure that the [clients_keystone] section of the configuration is
the preferred source when the context does not have the auth_uri.
"""
cfg.CONF.set_override('auth_uri', 'http://xyz',
@ -149,7 +149,9 @@ class TestRequestContext(common.HeatTestCase):
self.assertEqual(ctx.keystone_v3_endpoint, 'http://xyz/v3')
def test_keystone_v3_endpoint_in_keystone_authtoken_config(self):
"""Ensure that the [keystone_authtoken] section of the configuration
"""Ensure that the [keystone_authtoken] section is used.
Ensure that the [keystone_authtoken] section of the configuration
is used when the auth_uri is not defined in the context or the
[clients_keystone] section.
"""
@ -163,7 +165,9 @@ class TestRequestContext(common.HeatTestCase):
self.assertEqual(ctx.keystone_v3_endpoint, 'http://abc/v3')
def test_keystone_v3_endpoint_not_set_in_config(self):
"""Ensure an exception is raised when the auth_uri cannot be obtained
"""Ensure an exception is raised when the auth_uri cannot be obtained.
Ensure an exception is raised when the auth_uri cannot be obtained
from any source.
"""
policy_check = 'heat.common.policy.Enforcer.check_is_admin'

@ -278,13 +278,12 @@ class SchemaTest(common.HeatTestCase):
six.text_type(err))
def test_allowed_values_numeric_int(self):
'''
Test AllowedValues constraint for numeric integer values.
"""Test AllowedValues constraint for numeric integer values.
Test if the AllowedValues constraint works for numeric values in any
combination of numeric strings or numbers in the constraint and
numeric strings or numbers as value.
'''
"""
# Allowed values defined as integer numbers
schema = constraints.Schema(
@ -321,13 +320,12 @@ class SchemaTest(common.HeatTestCase):
six.text_type(err))
def test_allowed_values_numeric_float(self):
'''
Test AllowedValues constraint for numeric floating point values.
"""Test AllowedValues constraint for numeric floating point values.
Test if the AllowedValues constraint works for numeric values in any
combination of numeric strings or numbers in the constraint and
numeric strings or numbers as value.
'''
"""
# Allowed values defined as numbers
schema = constraints.Schema(
@ -364,7 +362,7 @@ class SchemaTest(common.HeatTestCase):
six.text_type(err))
def test_to_schema_type_int(self):
'''Test Schema.to_schema_type method for type Integer.'''
"""Test Schema.to_schema_type method for type Integer."""
schema = constraints.Schema('Integer')
# test valid values, i.e. integeres as string or number
res = schema.to_schema_type(1)
@ -384,7 +382,7 @@ class SchemaTest(common.HeatTestCase):
six.text_type(err))
def test_to_schema_type_num(self):
'''Test Schema.to_schema_type method for type Number.'''
"""Test Schema.to_schema_type method for type Number."""
schema = constraints.Schema('Number')
res = schema.to_schema_type(1)
self.assertIsInstance(res, int)
@ -400,7 +398,7 @@ class SchemaTest(common.HeatTestCase):
six.text_type(err))
def test_to_schema_type_string(self):
'''Test Schema.to_schema_type method for type String.'''
"""Test Schema.to_schema_type method for type String."""
schema = constraints.Schema('String')
res = schema.to_schema_type('one')
self.assertIsInstance(res, six.string_types)
@ -414,7 +412,7 @@ class SchemaTest(common.HeatTestCase):
self.assertIsInstance(res, six.string_types)
def test_to_schema_type_boolean(self):
'''Test Schema.to_schema_type method for type Boolean.'''
"""Test Schema.to_schema_type method for type Boolean."""
schema = constraints.Schema('Boolean')
true_values = [1, '1', True, 'true', 'True', 'yes', 'Yes']
@ -434,14 +432,14 @@ class SchemaTest(common.HeatTestCase):
six.text_type(err))
def test_to_schema_type_map(self):
'''Test Schema.to_schema_type method for type Map.'''
"""Test Schema.to_schema_type method for type Map."""
schema = constraints.Schema('Map')
res = schema.to_schema_type({'a': 'aa', 'b': 'bb'})
self.assertIsInstance(res, dict)
self.assertEqual({'a': 'aa', 'b': 'bb'}, res)
def test_to_schema_type_list(self):
'''Test Schema.to_schema_type method for type List.'''
"""Test Schema.to_schema_type method for type List."""
schema = constraints.Schema('List')
res = schema.to_schema_type(['a', 'b'])
self.assertIsInstance(res, list)

@ -133,6 +133,7 @@ class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase):
def _mock_convg_db_update_requires(self, key_id=False):
"""Updates requires column of resources.
Required for testing the generation of convergence dependency graph
on an update.
"""

@ -65,10 +65,11 @@ class CloudWatchAlarmTest(common.HeatTestCase):
return rsrc
def test_mem_alarm_high_update_no_replace(self):
'''
Make sure that we can change the update-able properties
"""Test case for updating the alarm with updatable properties.
Make sure that we can change the updatable properties
without replacing the Alarm rsrc.
'''
"""
t = template_format.parse(alarm_template)
# short circuit the alarm's references
@ -101,10 +102,11 @@ class CloudWatchAlarmTest(common.HeatTestCase):
self.m.VerifyAll()
def test_mem_alarm_high_update_replace(self):
'''
"""Test case for replacing the alarm with non-updatable properties.
Make sure that the Alarm resource IS replaced when non-update-able
properties are changed.
'''
"""
t = template_format.parse(alarm_template)
# short circuit the alarm's references

@ -52,8 +52,9 @@ rds_template = '''
class DBInstance(resource.Resource):
"""This is copied from the old DBInstance
to verify the schema of the new TemplateResource.
"""Verify the schema of the new TemplateResource.
This is copied from the old DBInstance.
"""
properties_schema = {
'DBSnapshotIdentifier': properties.Schema(
@ -152,9 +153,7 @@ class DBInstanceTest(common.HeatTestCase):
super(DBInstanceTest, self).setUp()
def test_dbinstance(self):
"""test that the Template is parsable and
publishes the correct properties.
"""
"""Test that Template is parsable and publishes correct properties."""
templ = template.Template(template_format.parse(rds_template))
stack = parser.Stack(utils.dummy_context(), 'test_stack',
templ)

@ -954,9 +954,7 @@ class FormatValidateParameterTest(common.HeatTestCase):
]
def test_format_validate_parameter(self):
"""
Test format of a parameter.
"""
"""Test format of a parameter."""
t = template_format.parse(self.template % self.param)
tmpl = template.Template(t)

@ -957,16 +957,15 @@ class StackServiceTest(common.HeatTestCase):
def test_list_template_functions(self, templ_mock):
class DummyFunc1(object):
"""
Dummy Func1
"""Dummy Func1.
Dummy Func1 Long Description
Dummy Func1 Long Description.
"""
class DummyFunc2(object):
"""Dummy Func2
"""Dummy Func2.
Dummy Func2 Long Description
Dummy Func2 Long Description.
"""
plugin_mock = mock.Mock(
@ -982,9 +981,9 @@ class StackServiceTest(common.HeatTestCase):
templ_mock.return_value = DummyMgr()
functions = self.eng.list_template_functions(self.ctx, 'dummytemplate')
expected = [{'functions': 'dummy1',
'description': 'Dummy Func1'},
'description': 'Dummy Func1.'},
{'functions': 'dummy2',
'description': 'Dummy Func2'}]
'description': 'Dummy Func2.'}]
self.assertEqual(sorted(expected, key=lambda k: k['functions']),
sorted(functions, key=lambda k: k['functions']))

@ -34,8 +34,10 @@ class StackServiceWatcherTest(common.HeatTestCase):
def test_periodic_watch_task_not_created(self, watch_rule_update,
watch_rule_get_all_by_stack,
stack_get_all_by_owner_id):
"""If there is no cloud watch lite alarm, then don't create
a periodic task for it.
"""Test case for not creating periodic task for cloud watch lite alarm.
If there is no cloud watch lite alarm, then don't create a periodic
task for it.
"""
stack_id = 83
watch_rule_get_all_by_stack.return_value = []
@ -56,8 +58,10 @@ class StackServiceWatcherTest(common.HeatTestCase):
def test_periodic_watch_task_created(self, watch_rule_update,
watch_rule_get_all_by_stack,
stack_get_all_by_owner_id):
"""If there is no cloud watch lite alarm, then DO create
a periodic task for it.
"""Test case for creating periodic task for cloud watch lite alarm.
If there is no cloud watch lite alarm, then DO create a periodic task
for it.
"""
stack_id = 86
wr1 = mock.Mock()

@ -289,8 +289,12 @@ class GlobalEnvLoadingTest(common.HeatTestCase):
m_ldir.assert_called_once_with(env_dir + '/*')
def test_continue_on_ioerror(self):
"""assert we get all files processed even if there are
processing exceptions.
"""Assert we get all files processed.
Assert we get all files processed even if there are processing
exceptions.
Test uses IOError as side effect of mock open.
"""
with mock.patch('glob.glob') as m_ldir:
m_ldir.return_value = ['/etc_etc/heat/environment.d/a.yaml',
@ -312,8 +316,12 @@ class GlobalEnvLoadingTest(common.HeatTestCase):
self.assertEqual(expected, m_open.call_args_list)
def test_continue_on_parse_error(self):
"""assert we get all files processed even if there are
processing exceptions.
"""Assert we get all files processed.
Assert we get all files processed even if there are processing
exceptions.
Test checks case when env content is incorrect.
"""
with mock.patch('glob.glob') as m_ldir:
m_ldir.return_value = ['/etc_etc/heat/environment.d/a.yaml',

@ -533,8 +533,7 @@ class HOTemplateTest(common.HeatTestCase):
self.assertEqual(snippet_resolved, self.resolve(snippet, tmpl))
def test_str_replace_syntax(self):
"""
Test str_replace function syntax.
"""Test str_replace function syntax.
Pass wrong syntax (array instead of dictionary) to function and
validate that we get a TypeError.
@ -548,8 +547,7 @@ class HOTemplateTest(common.HeatTestCase):
self.assertRaises(TypeError, self.resolve, snippet, tmpl)
def test_str_replace_invalid_param_keys(self):
"""
Test str_replace function parameter keys.
"""Test str_replace function parameter keys.
Pass wrong parameters to function and verify that we get
a KeyError.
@ -568,8 +566,7 @@ class HOTemplateTest(common.HeatTestCase):
self.assertRaises(KeyError, self.resolve, snippet, tmpl)
def test_str_replace_invalid_param_types(self):
"""
Test str_replace function parameter values.
"""Test str_replace function parameter values.
Pass parameter values of wrong type to function and verify that we get
a TypeError.
@ -755,9 +752,10 @@ class HOTemplateTest(common.HeatTestCase):
self.assertIn(item, snippet_resolved)
def test_repeat_bad_args(self):
"""
Test that the repeat function reports a proper error when missing
or invalid arguments.
"""Tests reporting error by repeat function.
Test that the repeat function reports a proper error when missing or
invalid arguments.
"""
tmpl = template.Template(hot_kilo_tpl_empty)
@ -871,7 +869,8 @@ class HOTemplateTest(common.HeatTestCase):
six.text_type(exc))
def test_prevent_parameters_access(self):
"""
"""Check parameters section inaccessible using the template as a dict.
Test that the parameters section can't be accessed using the template
as a dictionary.
"""
@ -898,7 +897,8 @@ class HOTemplateTest(common.HeatTestCase):
self.assertIn(err_str, six.text_type(keyError))
def test_parameters_section_not_iterable(self):
"""
"""Check parameters section is not returned using the template as iter.
Test that the parameters section is not returned when the template is
used as an iterable.
"""
@ -912,8 +912,7 @@ class HOTemplateTest(common.HeatTestCase):
self.assertNotIn('parameters', six.iterkeys(tmpl))
def test_invalid_hot_version(self):
"""
Test HOT version check.
"""Test HOT version check.
Pass an invalid HOT version to template.Template.__new__() and
validate that we get a ValueError.
@ -925,8 +924,7 @@ class HOTemplateTest(common.HeatTestCase):
template.Template, hot_tmpl)