Fix unused variables 2/2: enable unused var check

To make code simple and clean and enable unused local variables(F841)
check.

Change-Id: I420e4b3c8845efc616d447922122167af383dbc1
changes/27/62827/10
JUN JIE NAN 9 years ago
parent 9174668355
commit 6b1b49af7b
  1. 3
      contrib/rackspace/heat/tests/test_auto_scale.py
  2. 3
      contrib/rackspace/heat/tests/test_clouddatabase.py
  3. 2
      heat/api/cfn/v1/signal.py
  4. 2
      heat/api/cfn/v1/stacks.py
  5. 11
      heat/api/cloudwatch/watch.py
  6. 4
      heat/api/openstack/v1/actions.py
  7. 12
      heat/api/openstack/v1/stacks.py
  8. 2
      heat/common/plugin_loader.py
  9. 2
      heat/db/sqlalchemy/api.py
  10. 1
      heat/engine/parser.py
  11. 2
      heat/engine/properties.py
  12. 2
      heat/engine/resource.py
  13. 2
      heat/engine/resources/__init__.py
  14. 6
      heat/engine/resources/eip.py
  15. 2
      heat/engine/resources/security_group.py
  16. 2
      heat/engine/resources/template_resource.py
  17. 2
      heat/engine/service.py
  18. 8
      heat/tests/test_api_cfn_v1.py
  19. 61
      heat/tests/test_api_openstack_v1.py
  20. 4
      heat/tests/test_api_openstack_v1_views_stacks_view_builder.py
  21. 2
      heat/tests/test_auth_password.py
  22. 10
      heat/tests/test_engine_service.py
  23. 18
      heat/tests/test_instance_group.py
  24. 2
      heat/tests/test_nested_stack.py
  25. 5
      heat/tests/test_neutron_autoscaling.py
  26. 1
      heat/tests/test_os_database.py
  27. 20
      heat/tests/test_parser.py
  28. 2
      heat/tests/test_resource.py
  29. 31
      heat/tests/test_sqlalchemy_api.py
  30. 1
      heat/tests/test_volume.py
  31. 3
      tox.ini

@ -385,7 +385,6 @@ class PolicyTest(HeatTestCase):
template['Resources']['my_policy']['Properties']['changePercent'] = 10
del template['Resources']['my_policy']['Properties']['change']
self._setup_test_stack(template)
resource = self.stack['my_policy']
self.assertEqual(
self.fake_auto_scale.policies['0'].kwargs,
{
@ -405,7 +404,6 @@ class PolicyTest(HeatTestCase):
template['Resources']['my_policy']['Properties']['desiredCapacity'] = 1
del template['Resources']['my_policy']['Properties']['change']
self._setup_test_stack(template)
resource = self.stack['my_policy']
self.assertEqual(
self.fake_auto_scale.policies['0'].kwargs,
{
@ -422,7 +420,6 @@ class PolicyTest(HeatTestCase):
props['type'] = 'schedule'
props['args'] = {'cron': '0 0 0 * *'}
self._setup_test_stack(template)
resource = self.stack['my_policy']
self.assertEqual(
self.fake_auto_scale.policies['0'].kwargs,
{

@ -175,8 +175,7 @@ class CloudDBInstanceTest(HeatTestCase):
def test_clouddbinstance_delete(self):
instance = self._setup_test_clouddbinstance('dbinstance_delete')
fake_client = self.m.CreateMockAnything()
cloud_db = instance.cloud_db().AndReturn(fake_client)
fakedbinstance = FakeDBInstance()
instance.cloud_db().AndReturn(fake_client)
fake_client.delete(1234).AndReturn(None)
self.m.ReplayAll()
instance.handle_delete()

@ -42,7 +42,7 @@ class SignalController(object):
con = req.context
identity = identifier.ResourceIdentifier.from_arn(arn)
try:
md = self.engine.resource_signal(
self.engine.resource_signal(
con,
stack_identity=dict(identity.stack()),
resource_name=identity.resource_name,

@ -56,7 +56,7 @@ class StackController(object):
except heat_exception.Forbidden:
msg = _('Action %s not allowed for user') % action
raise exception.HeatAccessDeniedError(msg)
except Exception as ex:
except Exception:
# We expect policy.enforce to either pass or raise Forbidden
# however, if anything else happens, we want to raise
# HeatInternalFailureError, failure to do this results in

@ -50,7 +50,7 @@ class WatchController(object):
except heat_exception.Forbidden:
msg = _("Action %s not allowed for user") % action
raise exception.HeatAccessDeniedError(msg)
except Exception as ex:
except Exception:
# We expect policy.enforce to either pass or raise Forbidden
# however, if anything else happens, we want to raise
# HeatInternalFailureError, failure to do this results in
@ -327,15 +327,6 @@ class WatchController(object):
logger.error(msg)
return exception.HeatInvalidParameterValueError(msg)
# Check for optional parameters
# FIXME : We don't actually do anything with these in the engine yet..
state_reason = None
state_reason_data = None
if 'StateReason' in parms:
state_reason = parms['StateReason']
if 'StateReasonData' in parms:
state_reason_data = parms['StateReasonData']
logger.debug(_("setting %(name)s to %(state)s") % {
'name': name, 'state': state_map[state]})
try:

@ -52,9 +52,9 @@ class ActionController(object):
raise exc.HTTPBadRequest(_("Invalid action %s specified") % ac)
if ac == self.SUSPEND:
res = self.engine.stack_suspend(req.context, identity)
self.engine.stack_suspend(req.context, identity)
elif ac == self.RESUME:
res = self.engine.stack_resume(req.context, identity)
self.engine.stack_resume(req.context, identity)
else:
raise exc.HTTPInternalServerError(_("Unexpected action %s") % ac)

@ -270,12 +270,12 @@ class StackController(object):
"""
data = InstantiationData(body)
res = self.engine.update_stack(req.context,
identity,
data.template(),
data.environment(),
data.files(),
data.args())
self.engine.update_stack(req.context,
identity,
data.template(),
data.environment(),
data.files(),
data.args())
raise exc.HTTPAccepted()

@ -90,7 +90,7 @@ def load_modules(package, ignore_error=False):
pkg_prefix):
try:
module = _import_module(importer, module_name, package)
except ImportError as ex:
except ImportError:
logger.error(_('Failed to import module %s') % module_name)
if not ignore_error:
raise

@ -375,8 +375,6 @@ def stack_update(context, stack_id, values):
'id': stack_id,
'msg': 'that does not exist'})
old_template_id = stack.raw_template_id
stack.update(values)
stack.save(_session(context))

@ -395,7 +395,6 @@ class Stack(collections.Mapping):
stack_status = self.COMPLETE
reason = 'Stack %s completed successfully' % action.lower()
res = None
def resource_action(r):
# Find e.g resource.create and call it

@ -278,7 +278,7 @@ class Property(object):
isinstance(value, basestring)):
raise TypeError(_('"%s" is not a list') % repr(value))
return [v for i, v in self._validate_children(enumerate(value),
return [v[1] for v in self._validate_children(enumerate(value),
range(len(value)))]
def _validate_bool(self, value):

@ -321,7 +321,7 @@ class Resource(object):
if key in ('DependsOn', 'Ref', 'Fn::GetAtt', 'get_attr',
'get_resource'):
if key in ('Fn::GetAtt', 'get_attr'):
res_name, att = value
res_name = value[0]
res_list = [res_name]
elif key == 'DependsOn' and isinstance(value, list):
res_list = value

@ -37,7 +37,7 @@ def _get_module_resources(module):
if callable(getattr(module, 'resource_mapping', None)):
try:
return module.resource_mapping().iteritems()
except Exception as ex:
except Exception:
LOG.error(_('Failed to load resources from %s') % str(module))
else:
return []

@ -113,7 +113,7 @@ class ElasticIp(resource.Resource):
instance_id = self.properties[self.INSTANCE_ID]
if instance_id:
server = self.nova().servers.get(instance_id)
res = server.add_floating_ip(self._ipaddress())
server.add_floating_ip(self._ipaddress())
def handle_delete(self):
instance_id = self.properties[self.INSTANCE_ID]
@ -122,7 +122,7 @@ class ElasticIp(resource.Resource):
server = self.nova().servers.get(instance_id)
if server:
server.remove_floating_ip(self._ipaddress())
except clients.novaclient.exceptions.NotFound as ex:
except clients.novaclient.exceptions.NotFound:
pass
"""De-allocate a floating IP."""
@ -240,7 +240,7 @@ class ElasticIpAssociation(resource.Resource):
server = self.nova().servers.get(instance_id)
if server:
server.remove_floating_ip(self.properties[self.EIP])
except clients.novaclient.exceptions.NotFound as ex:
except clients.novaclient.exceptions.NotFound:
pass
elif self.properties[self.ALLOCATION_ID]:
float_id = self.properties[self.ALLOCATION_ID]

@ -201,7 +201,7 @@ class SecurityGroup(resource.Resource):
source_group_id = group.id
break
try:
rule = rules_client.create(
rules_client.create(
sec.id,
i.get(self.RULE_IP_PROTOCOL),
i.get(self.RULE_FROM_PORT),

@ -195,7 +195,7 @@ class TemplateResource(stack_resource.StackResource):
raise exception.StackValidationFailed(message=msg)
try:
td = self.template_data()
self.template_data()
except ValueError as ex:
msg = _("Failed to retrieve template data: %s") % str(ex)
raise exception.StackValidationFailed(message=msg)

@ -763,7 +763,7 @@ class EngineService(service.Service):
# heat_keystoneclient populates the context with an auth_token
# either via the stored user/password or trust_id, depending
# on how deferred_auth_method is configured in the conf file
kc = hkc.KeystoneClient(stored_context)
hkc.KeystoneClient(stored_context)
return stored_context
@request_context

@ -712,8 +712,6 @@ class CfnStackControllerTest(HeatTestCase):
'OnFailure': 'DO_NOTHING',
'Parameters.member.1.ParameterKey': 'InstanceType',
'Parameters.member.1.ParameterValue': 'm1.xlarge'}
engine_parms = {u'InstanceType': u'm1.xlarge'}
engine_args = {'timeout_mins': u'30', 'disable_rollback': 'false'}
dummy_req = self._dummy_GET_request(params)
self._stub_enforce(dummy_req, 'CreateStack')
@ -1010,7 +1008,6 @@ class CfnStackControllerTest(HeatTestCase):
def test_get_template_err_rpcerr(self):
stack_name = "wordpress"
identity = dict(identifier.HeatIdentifier('t', stack_name, '6'))
template = {u'Foo': u'bar'}
params = {'Action': 'GetTemplate', 'StackName': stack_name}
dummy_req = self._dummy_GET_request(params)
self._stub_enforce(dummy_req, 'GetTemplate')
@ -1062,7 +1059,6 @@ class CfnStackControllerTest(HeatTestCase):
def test_get_template_err_none(self):
stack_name = "wordpress"
identity = dict(identifier.HeatIdentifier('t', stack_name, '6'))
template = {u'Foo': u'bar'}
params = {'Action': 'GetTemplate', 'StackName': stack_name}
dummy_req = self._dummy_GET_request(params)
self._stub_enforce(dummy_req, 'GetTemplate')
@ -1092,7 +1088,6 @@ class CfnStackControllerTest(HeatTestCase):
def test_validate_err_no_template(self):
# Format a dummy request with a missing template field
stack_name = "wordpress"
params = {'Action': 'ValidateTemplate'}
dummy_req = self._dummy_GET_request(params)
self._stub_enforce(dummy_req, 'ValidateTemplate')
@ -1420,7 +1415,6 @@ class CfnStackControllerTest(HeatTestCase):
def test_describe_stack_resource_nonexistent_stack(self):
# Format a dummy request
stack_name = "wibble"
identity = dict(identifier.HeatIdentifier('t', stack_name, '6'))
params = {'Action': 'DescribeStackResource',
'StackName': stack_name,
'LogicalResourceId': "WikiDatabase"}
@ -1642,8 +1636,6 @@ class CfnStackControllerTest(HeatTestCase):
def test_describe_stack_resources_physical_not_found(self):
# Format a dummy request
stack_name = "wordpress"
identity = dict(identifier.HeatIdentifier('t', stack_name, '6'))
params = {'Action': 'DescribeStackResources',
'LogicalResourceId': "WikiDatabase",
'PhysicalResourceId': 'aaaaaaaa-9f88-404d-cccc-ffffffffffff'}

@ -392,7 +392,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
req = self._get('/stacks', params=params)
mock_call.return_value = []
result = self.controller.index(req, tenant_id=self.tenant)
self.controller.index(req, tenant_id=self.tenant)
rpc_call_args, _ = mock_call.call_args
engine_args = rpc_call_args[2]['args']
@ -415,7 +415,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
req = self._get('/stacks', params=params)
mock_call.return_value = []
result = self.controller.index(req, tenant_id=self.tenant)
self.controller.index(req, tenant_id=self.tenant)
rpc_call_args, _ = mock_call.call_args
engine_args = rpc_call_args[2]['args']
@ -587,7 +587,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self._mock_enforce_setup(mock_enforce, 'create', True)
identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '1')
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
parameters = {u'InstanceType': u'm1.xlarge'}
body = {'template': template,
'stack_name': identity.stack_name,
@ -625,7 +624,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self._mock_enforce_setup(mock_enforce, 'create', True)
identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '1')
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
parameters = {u'InstanceType': u'm1.xlarge'}
body = {'template': template,
'stack_name': identity.stack_name,
@ -664,7 +662,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
stack_name = "wordpress"
template = {u'Foo': u'bar'}
parameters = {u'InstanceType': u'm1.xlarge'}
json_template = json.dumps(template)
body = {'template': template,
'stack_name': stack_name,
'parameters': parameters,
@ -736,7 +733,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
stack_name = "wordpress"
template = {u'Foo': u'bar'}
parameters = {u'InstanceType': u'm1.xlarge'}
json_template = json.dumps(template)
body = {'template': template,
'stack_name': stack_name,
'parameters': parameters,
@ -772,7 +768,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
stack_name = "wordpress"
template = {u'Foo': u'bar'}
parameters = {u'InstanceType': u'm1.xlarge'}
json_template = json.dumps(template)
body = {'template': template,
'stack_name': stack_name,
'parameters': parameters,
@ -792,7 +787,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
stack_name = "wordpress"
template = {u'Foo': u'bar'}
parameters = {u'InstanceType': u'm1.xlarge'}
json_template = json.dumps(template)
body = {'template': template,
'stack_name': stack_name,
'parameters': parameters,
@ -1186,10 +1180,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
def test_update(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'update', True)
identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '6')
stack_name = u'wordpress'
stack_id = u'6'
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
parameters = {u'InstanceType': u'm1.xlarge'}
body = {'template': template,
'parameters': parameters,
@ -1225,7 +1216,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self._mock_enforce_setup(mock_enforce, 'update', True)
identity = identifier.HeatIdentifier(self.tenant, 'wibble', '6')
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
parameters = {u'InstanceType': u'm1.xlarge'}
body = {'template': template,
'parameters': parameters,
@ -1265,7 +1255,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self._mock_enforce_setup(mock_enforce, 'update', False)
identity = identifier.HeatIdentifier(self.tenant, 'wibble', '6')
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
parameters = {u'InstanceType': u'm1.xlarge'}
body = {'template': template,
'parameters': parameters,
@ -1288,12 +1277,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
def test_delete(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'delete', True)
identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '6')
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
parameters = {u'InstanceType': u'm1.xlarge'}
body = {'template': template,
'parameters': parameters,
'timeout_mins': 30}
req = self._delete('/stacks/%(stack_name)s/%(stack_id)s' % identity)
@ -1317,12 +1300,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
def test_delete_err_denied_policy(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'delete', False)
identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '6')
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
parameters = {u'InstanceType': u'm1.xlarge'}
body = {'template': template,
'parameters': parameters,
'timeout_mins': 30}
req = self._delete('/stacks/%(stack_name)s/%(stack_id)s' % identity)
@ -1338,9 +1315,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
def test_abandon(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'abandon', True)
identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '6')
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
parameters = {u'InstanceType': u'm1.xlarge'}
req = self._abandon('/stacks/%(stack_name)s/%(stack_id)s' % identity)
self.m.StubOutWithMock(rpc, 'call')
@ -1364,12 +1338,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
def test_abandon_err_denied_policy(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'abandon', False)
identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '6')
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
parameters = {u'InstanceType': u'm1.xlarge'}
body = {'template': template,
'parameters': parameters,
'timeout_mins': 30}
req = self._abandon('/stacks/%(stack_name)s/%(stack_id)s' % identity)
@ -1385,12 +1353,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
def test_delete_bad_name(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'delete', True)
identity = identifier.HeatIdentifier(self.tenant, 'wibble', '6')
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
parameters = {u'InstanceType': u'm1.xlarge'}
body = {'template': template,
'parameters': parameters,
'timeout_mins': 30}
req = self._delete('/stacks/%(stack_name)s/%(stack_id)s' % identity)
@ -1418,7 +1380,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
def test_validate_template(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'validate_template', True)
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
body = {'template': template}
req = self._post('/validate', json.dumps(body))
@ -1452,7 +1413,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
def test_validate_template_error(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'validate_template', True)
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
body = {'template': template}
req = self._post('/validate', json.dumps(body))
@ -1474,7 +1434,6 @@ class StackControllerTest(ControllerTest, HeatTestCase):
def test_validate_err_denied_policy(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'validate_template', False)
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
body = {'template': template}
req = self._post('/validate', json.dumps(body))
@ -1531,11 +1490,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
def test_list_resource_types_err_denied_policy(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'list_resource_types', False)
template = {u'Foo': u'bar'}
json_template = json.dumps(template)
req = self._get('/resource_types')
resp = request_with_middleware(fault.FaultWrapper,
self.controller.list_resource_types,
req, tenant_id=self.tenant)
@ -1779,8 +1734,8 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
res_name = 'WikiDatabase'
stack_identity = identifier.HeatIdentifier(self.tenant,
'wordpress', '1')
res_identity = identifier.ResourceIdentifier(resource_name=res_name,
**stack_identity)
identifier.ResourceIdentifier(resource_name=res_name,
**stack_identity)
req = self._get(stack_identity._tenant_path() + '/resources')
@ -2922,7 +2877,6 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
def test_action_suspend(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'action', True)
res_name = 'WikiDatabase'
stack_identity = identifier.HeatIdentifier(self.tenant,
'wordpress', '1')
body = {'suspend': None}
@ -2947,7 +2901,6 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
def test_action_resume(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'action', True)
res_name = 'WikiDatabase'
stack_identity = identifier.HeatIdentifier(self.tenant,
'wordpress', '1')
body = {'resume': None}
@ -2972,7 +2925,6 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
def test_action_badaction(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'action', True)
res_name = 'WikiDatabase'
stack_identity = identifier.HeatIdentifier(self.tenant,
'wordpress', '1')
body = {'notallowed': None}
@ -2990,7 +2942,6 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
def test_action_badaction_empty(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'action', True)
res_name = 'WikiDatabase'
stack_identity = identifier.HeatIdentifier(self.tenant,
'wordpress', '1')
body = {}
@ -3008,7 +2959,6 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
def test_action_badaction_multiple(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'action', True)
res_name = 'WikiDatabase'
stack_identity = identifier.HeatIdentifier(self.tenant,
'wordpress', '1')
body = {'one': None, 'two': None}
@ -3026,7 +2976,6 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
def test_action_rmt_aterr(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'action', True)
res_name = 'WikiDatabase'
stack_identity = identifier.HeatIdentifier(self.tenant,
'wordpress', '1')
body = {'suspend': None}
@ -3055,7 +3004,6 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
def test_action_err_denied_policy(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'action', False)
res_name = 'WikiDatabase'
stack_identity = identifier.HeatIdentifier(self.tenant,
'wordpress', '1')
body = {'suspend': None}
@ -3073,7 +3021,6 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
def test_action_badaction_ise(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'action', True)
res_name = 'WikiDatabase'
stack_identity = identifier.HeatIdentifier(self.tenant,
'wordpress', '1')
body = {'oops': None}

@ -16,7 +16,6 @@ import mock
from heat.tests.common import HeatTestCase
from heat.api.openstack.v1.views import stacks_view
from heat.engine import parser
from heat.common import identifier
@ -84,7 +83,6 @@ class TestStacksViewBuilder(HeatTestCase):
super(TestStacksViewBuilder, self).setUp()
self.request = mock.Mock()
self.request.params = {}
template = parser.Template({})
identity = identifier.HeatIdentifier('123456', 'wordpress', '1')
self.stack1 = {
u'stack_identity': dict(identity),
@ -115,7 +113,7 @@ class TestStacksViewBuilder(HeatTestCase):
stacks = [self.stack1]
expected_keys = stacks_view.basic_keys
stack_view = stacks_view.collection(self.request, stacks)
stacks_view.collection(self.request, stacks)
mock_format_stack.assert_called_once_with(self.request,
self.stack1,
expected_keys)

@ -174,5 +174,5 @@ class KeystonePasswordAuthProtocolTest(HeatTestCase):
req = webob.Request.blank('/tenant_id1/')
req.headers['X_AUTH_USER'] = 'user_name1'
req.headers['X_AUTH_KEY'] = 'goodpassword'
response = self.middleware(req.environ, self._start_fake_response)
self.middleware(req.environ, self._start_fake_response)
self.assertEqual(self.response_status, 400)

@ -837,8 +837,6 @@ class StackServiceUpdateNotSupportedTest(HeatTestCase):
sid = old_stack.store()
s = db_api.stack_get(self.ctx, sid)
stack = get_wordpress_stack(stack_name, self.ctx)
self.m.StubOutWithMock(parser, 'Stack')
self.m.StubOutWithMock(parser.Stack, 'load')
parser.Stack.load(self.ctx, stack=s).AndReturn(old_stack)
@ -1577,10 +1575,10 @@ class StackServiceTest(HeatTestCase):
rsrs.Resource.signal(mox.IgnoreArg()).AndReturn(None)
self.m.ReplayAll()
result = self.eng.resource_signal(self.ctx,
dict(self.stack.identifier()),
'WebServerScaleDownPolicy',
test_data)
self.eng.resource_signal(self.ctx,
dict(self.stack.identifier()),
'WebServerScaleDownPolicy',
test_data)
self.m.VerifyAll()
self.stack.delete()

@ -100,7 +100,7 @@ class InstanceGroupTest(HeatTestCase):
instance.Instance.FnGetAtt('PublicIp').AndReturn('1.2.3.4')
self.m.ReplayAll()
conf = self.create_resource(t, stack, 'JobServerConfig')
self.create_resource(t, stack, 'JobServerConfig')
rsrc = self.create_resource(t, stack, 'JobServerGroup')
self.assertEqual(utils.PhysName(stack.name, rsrc.name),
rsrc.FnGetRefId())
@ -133,7 +133,7 @@ class InstanceGroupTest(HeatTestCase):
self._stub_create(1, instance_class=MyInstance)
self.m.ReplayAll()
conf = self.create_resource(t, stack, 'JobServerConfig')
self.create_resource(t, stack, 'JobServerConfig')
rsrc = self.create_resource(t, stack, 'JobServerGroup')
self.assertEqual(utils.PhysName(stack.name, rsrc.name),
rsrc.FnGetRefId())
@ -145,7 +145,7 @@ class InstanceGroupTest(HeatTestCase):
t = template_format.parse(ig_template)
stack = utils.parse_stack(t)
conf = self.create_resource(t, stack, 'JobServerConfig')
self.create_resource(t, stack, 'JobServerConfig')
rsrc = stack['JobServerGroup']
self.m.StubOutWithMock(instance.Instance, 'handle_create')
@ -170,7 +170,7 @@ class InstanceGroupTest(HeatTestCase):
self._stub_create(2)
self.m.ReplayAll()
conf = self.create_resource(t, stack, 'JobServerConfig')
self.create_resource(t, stack, 'JobServerConfig')
rsrc = self.create_resource(t, stack, 'JobServerGroup')
self.m.VerifyAll()
@ -213,7 +213,7 @@ class InstanceGroupTest(HeatTestCase):
instance.Instance.handle_create().AndRaise(Exception)
self.m.ReplayAll()
conf = self.create_resource(t, stack, 'JobServerConfig')
self.create_resource(t, stack, 'JobServerConfig')
self.assertRaises(
exception.ResourceFailure,
self.create_resource, t, stack, 'JobServerGroup')
@ -240,7 +240,7 @@ class InstanceGroupTest(HeatTestCase):
self._stub_create(1)
self.m.ReplayAll()
conf = self.create_resource(t, stack, 'JobServerConfig')
self.create_resource(t, stack, 'JobServerConfig')
rsrc = self.create_resource(t, stack, 'JobServerGroup')
self.assertEqual(len(rsrc.nested().resources), 1)
succeeded_instance = rsrc.nested().resources.values()[0]
@ -257,8 +257,6 @@ class InstanceGroupTest(HeatTestCase):
update_snippet = copy.deepcopy(rsrc.parsed_template())
update_snippet['Properties']['Size'] = '2'
tmpl_diff = {'Properties': {'Size': '2'}}
prop_diff = {'Size': '2'}
updater = scheduler.TaskRunner(rsrc.update, update_snippet)
self.assertRaises(exception.ResourceFailure, updater)
@ -281,7 +279,7 @@ class InstanceGroupTest(HeatTestCase):
self._stub_create(2)
self.m.ReplayAll()
conf = self.create_resource(t, stack, 'JobServerConfig')
self.create_resource(t, stack, 'JobServerConfig')
rsrc = self.create_resource(t, stack, 'JobServerGroup')
self.m.ReplayAll()
@ -302,7 +300,7 @@ class InstanceGroupTest(HeatTestCase):
self._stub_create(2)
self.m.ReplayAll()
conf = self.create_resource(t, stack, 'JobServerConfig')
self.create_resource(t, stack, 'JobServerConfig')
rsrc = self.create_resource(t, stack, 'JobServerGroup')
self.m.ReplayAll()

@ -247,7 +247,6 @@ Outputs:
rsrc = stack['the_nested']
original_nested_id = rsrc.resource_id
t = template_format.parse(self.test_template)
new_res = copy.deepcopy(t['Resources']['the_nested'])
new_res['Properties']['TemplateURL'] = (
@ -289,7 +288,6 @@ Outputs:
rsrc = stack['the_nested']
original_nested_id = rsrc.resource_id
t = template_format.parse(self.test_template)
new_res = copy.deepcopy(t['Resources']['the_nested'])
new_res['Properties']['TemplateURL'] = (

@ -262,11 +262,6 @@ class AutoScalingTest(HeatTestCase):
self.id = id
self.name = name
image_list = [id_type(id='768b5464-3df5-4abf-be33-63b60f8b99d0',
name='foo')]
flavor_list = [id_type(id='768b5464-3df5-4abf-be33-63b60f8b99d1',
name='bar')]
instances = {}
clients.OpenStackClients.keystone().AndReturn(

@ -197,7 +197,6 @@ class OSDBInstanceTest(HeatTestCase):
self.m.VerifyAll()
def test_osdatabase_invalid_attribute(self):
fake_dbinstance = FakeDBInstance()
t = template_format.parse(wp_template)
instance = self._setup_test_clouddbinstance("db_invalid_attrib", t)
attrib = instance._resolve_attribute("invalid_attrib")

@ -883,12 +883,6 @@ class StackTest(HeatTestCase):
tpl = {'Resources':
{'A': {'Type': 'GenericResourceType'},
'B': {'Type': 'GenericResourceType'}}}
resources = '''{'A': {'status': 'COMPLETE', 'name': 'A',
'resource_data': {}, 'resource_id': None, 'action': 'INIT',
'type': 'GenericResourceType', 'metadata': {}},
'B': {'status': 'COMPLETE', 'name': 'B', 'resource_data': {},
'resource_id': None, 'action': 'INIT', 'type': 'GenericResourceType',
'metadata': {}}}'''
stack = parser.Stack(self.ctx,
'stack_details_test',
parser.Template(tpl))
@ -1050,7 +1044,7 @@ class StackTest(HeatTestCase):
tmpl = {'Resources': {'AResource': {'Type': 'GenericResourceType'}}}
self.stack = parser.Stack(self.ctx, 'suspend_test',
parser.Template(tmpl))
stack_id = self.stack.store()
self.stack.store()
self.stack.create()
self.assertEqual(self.stack.state,
(self.stack.CREATE, self.stack.COMPLETE))
@ -1078,7 +1072,7 @@ class StackTest(HeatTestCase):
self.stack = parser.Stack(self.ctx, 'suspend_test_fail',
parser.Template(tmpl))
stack_id = self.stack.store()
self.stack.store()
self.stack.create()
self.assertEqual(self.stack.state,
(self.stack.CREATE, self.stack.COMPLETE))
@ -1101,7 +1095,7 @@ class StackTest(HeatTestCase):
self.stack = parser.Stack(self.ctx, 'resume_test_fail',
parser.Template(tmpl))
stack_id = self.stack.store()
self.stack.store()
self.stack.create()
self.assertEqual(self.stack.state,
(self.stack.CREATE, self.stack.COMPLETE))
@ -1130,7 +1124,7 @@ class StackTest(HeatTestCase):
self.stack = parser.Stack(self.ctx, 'suspend_test_fail_timeout',
parser.Template(tmpl))
stack_id = self.stack.store()
self.stack.store()
self.stack.create()
self.assertEqual(self.stack.state,
(self.stack.CREATE, self.stack.COMPLETE))
@ -1153,7 +1147,7 @@ class StackTest(HeatTestCase):
self.stack = parser.Stack(self.ctx, 'resume_test_fail_timeout',
parser.Template(tmpl))
stack_id = self.stack.store()
self.stack.store()
self.stack.create()
self.assertEqual(self.stack.state,
(self.stack.CREATE, self.stack.COMPLETE))
@ -1208,7 +1202,7 @@ class StackTest(HeatTestCase):
self.stack = parser.Stack(self.ctx, 'test_stack', parser.Template({}),
action=parser.Stack.CREATE,
status=parser.Stack.FAILED)
stack_id = self.stack.store()
self.stack.store()
self.assertEqual(self.stack.state,
(parser.Stack.CREATE, parser.Stack.FAILED))
self.stack.update({})
@ -1929,7 +1923,7 @@ class StackTest(HeatTestCase):
self.stack = parser.Stack(self.ctx, 'delete_test_fail',
parser.Template(tmpl))
stack_id = self.stack.store()
self.stack.store()
self.stack.create()
self.assertEqual(self.stack.state,
(self.stack.CREATE, self.stack.COMPLETE))

@ -179,7 +179,7 @@ class ResourceTest(HeatTestCase):
self.assertEqual(res.status, res.IN_PROGRESS)
self.assertEqual(res.status_reason, 'test_store')
db_res = r = db_api.resource_get(res.context, res.id)
db_res = db_api.resource_get(res.context, res.id)
self.assertEqual(db_res.action, res.CREATE)
self.assertEqual(db_res.status, res.IN_PROGRESS)
self.assertEqual(db_res.status_reason, 'test_store')

@ -267,9 +267,8 @@ class SqlAlchemyTest(HeatTestCase):
self.assertEqual(1, len(st_db))
def test_stack_get_all_by_tenant_and_filters(self):
stack1 = self._setup_test_stack('foo', UUID1)
stack2 = self._setup_test_stack('bar', UUID2)
stacks = [stack1, stack2]
self._setup_test_stack('foo', UUID1)
self._setup_test_stack('bar', UUID2)
filters = {'name': 'foo'}
results = db_api.stack_get_all_by_tenant(self.ctx,
@ -279,9 +278,8 @@ class SqlAlchemyTest(HeatTestCase):
self.assertEqual('foo', results[0]['name'])
def test_stack_get_all_by_tenant_filter_matches_in_list(self):
stack1 = self._setup_test_stack('foo', UUID1)
stack2 = self._setup_test_stack('bar', UUID2)
stacks = [stack1, stack2]
self._setup_test_stack('foo', UUID1)
self._setup_test_stack('bar', UUID2)
filters = {'name': ['bar', 'quux']}
results = db_api.stack_get_all_by_tenant(self.ctx,
@ -291,9 +289,8 @@ class SqlAlchemyTest(HeatTestCase):
self.assertEqual('bar', results[0]['name'])
def test_stack_get_all_by_tenant_returns_all_if_no_filters(self):
stack1 = self._setup_test_stack('foo', UUID1)
stack2 = self._setup_test_stack('bar', UUID2)
stacks = [stack1, stack2]
self._setup_test_stack('foo', UUID1)
self._setup_test_stack('bar', UUID2)
filters = None
results = db_api.stack_get_all_by_tenant(self.ctx,
@ -332,8 +329,8 @@ class SqlAlchemyTest(HeatTestCase):
@mock.patch.object(db_api.utils, 'paginate_query')
def test_stack_get_all_by_tenant_filters_sort_keys(self, mock_paginate):
sort_keys = ['name', 'status', 'created_at', 'updated_at', 'username']
st_db = db_api.stack_get_all_by_tenant(self.ctx,
sort_keys=sort_keys)
db_api.stack_get_all_by_tenant(self.ctx,
sort_keys=sort_keys)
args, _ = mock_paginate.call_args
used_sort_keys = set(args[3])
@ -349,17 +346,17 @@ class SqlAlchemyTest(HeatTestCase):
self.assertEqual(stacks[0].id, st_db[0].id)
def test_stack_get_all_by_tenant_non_existing_marker(self):
stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]
[self._setup_test_stack('stack', x)[1] for x in UUIDs]
uuid = 'this stack doesnt exist'
st_db = db_api.stack_get_all_by_tenant(self.ctx, marker=uuid)
self.assertEqual(3, len(st_db))
def test_stack_get_all_by_tenant_doesnt_mutate_sort_keys(self):
stacks = [self._setup_test_stack('stack', x)[1] for x in UUIDs]
[self._setup_test_stack('stack', x)[1] for x in UUIDs]
sort_keys = ['id']
st_db = db_api.stack_get_all_by_tenant(self.ctx, sort_keys=sort_keys)
db_api.stack_get_all_by_tenant(self.ctx, sort_keys=sort_keys)
self.assertEqual(['id'], sort_keys)
def test_stack_count_all_by_tenant(self):
@ -377,9 +374,9 @@ class SqlAlchemyTest(HeatTestCase):
self.assertEqual(1, st_db)
def test_stack_count_all_by_tenant_with_filters(self):
stack1 = self._setup_test_stack('foo', UUID1)
stack2 = self._setup_test_stack('bar', UUID2)
stack3 = self._setup_test_stack('bar', UUID3)
self._setup_test_stack('foo', UUID1)
self._setup_test_stack('bar', UUID2)
self._setup_test_stack('bar', UUID3)
filters = {'name': 'bar'}
st_db = db_api.stack_count_all_by_tenant(self.ctx, filters=filters)

@ -440,7 +440,6 @@ class VolumeTest(HeatTestCase):
def test_volume_delete(self):
stack_name = 'test_volume_stack'
fv = FakeVolume('creating', 'available')
fb = FakeBackup('creating', 'available')
self._mock_create_volume(fv, stack_name)
self.m.ReplayAll()

@ -39,12 +39,11 @@ deps = -r{toxinidir}/requirements.txt
commands = python setup.py build_sphinx
[flake8]
# F841 local variable 'json_template' is assigned to but never used
# H201 no 'except:' at least use 'except Exception:'
# H302 import only modules.'bla..' does not import a module
# H306 imports not in alphabetical order
# H404 multi line docstring should start with a summary
ignore = F841,H201,H302,H306,H404,H803
ignore = H201,H302,H306,H404,H803
show-source = true
builtins = _
exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,tools,build

Loading…
Cancel
Save