Fix order of arguments in assertEqual (patch 1/2)

Some tests used incorrect order assertEqual(observed, expected).

The correct order expected by testtools is
assertEqual(expected, observed).

This patch includes roughly half of the files touched by these changes
(up to and including test_m* sans contrib code) to ease the review.

Partial-Bug: #1259292

Change-Id: I44bff827c7c50726d48aa649b7685712a233ee62
changes/57/61457/8
Pavlo Shchelokovskyy 9 years ago
parent cb8404910b
commit 499b7cccac
  1. 68
      heat/tests/test_api_aws.py
  2. 36
      heat/tests/test_api_cfn_v1.py
  3. 50
      heat/tests/test_api_ec2token.py
  4. 205
      heat/tests/test_api_openstack_v1.py
  5. 10
      heat/tests/test_auth_password.py
  6. 146
      heat/tests/test_autoscaling.py
  7. 62
      heat/tests/test_autoscaling_update_policy.py
  8. 8
      heat/tests/test_common_context.py
  9. 4
      heat/tests/test_common_policy.py
  10. 8
      heat/tests/test_cw_alarm.py
  11. 28
      heat/tests/test_dependencies.py
  12. 6
      heat/tests/test_engine_api_utils.py
  13. 4
      heat/tests/test_engine_service.py
  14. 6
      heat/tests/test_heatclient.py
  15. 36
      heat/tests/test_hot.py
  16. 180
      heat/tests/test_identifier.py
  17. 77
      heat/tests/test_instance.py
  18. 6
      heat/tests/test_instance_group.py
  19. 62
      heat/tests/test_instance_group_update_policy.py
  20. 16
      heat/tests/test_instance_network.py
  21. 18
      heat/tests/test_iso8601_utils.py
  22. 26
      heat/tests/test_metadata_refresh.py

@ -25,7 +25,7 @@ class AWSCommonTest(HeatTestCase):
def test_format_response(self):
response = api_utils.format_response("Foo", "Bar")
expected = {'FooResponse': {'FooResult': 'Bar'}}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_params_extract(self):
p = {'Parameters.member.1.ParameterKey': 'foo',
@ -35,11 +35,11 @@ class AWSCommonTest(HeatTestCase):
params = api_utils.extract_param_pairs(p, prefix='Parameters',
keyname='ParameterKey',
valuename='ParameterValue')
self.assertEqual(len(params), 2)
self.assertEqual(2, len(params))
self.assertIn('foo', params)
self.assertEqual(params['foo'], 'bar')
self.assertEqual('bar', params['foo'])
self.assertIn('blarg', params)
self.assertEqual(params['blarg'], 'wibble')
self.assertEqual('wibble', params['blarg'])
def test_params_extract_dots(self):
p = {'Parameters.member.1.1.ParameterKey': 'foo',
@ -59,9 +59,9 @@ class AWSCommonTest(HeatTestCase):
params = api_utils.extract_param_pairs(p, prefix='Parameters',
keyname='ParameterKey',
valuename='ParameterValue')
self.assertEqual(len(params), 1)
self.assertEqual(1, len(params))
self.assertIn('foo', params)
self.assertEqual(params['foo'], 'bar')
self.assertEqual('bar', params['foo'])
def test_params_extract_garbage_prefix(self):
p = {'prefixParameters.member.Foo.Bar.ParameterKey': 'foo',
@ -84,44 +84,44 @@ class AWSCommonTest(HeatTestCase):
'MetricData.member.1.Unit': 'Bytes',
'MetricData.member.1.Value': 234333}
params = api_utils.extract_param_list(p, prefix='MetricData')
self.assertEqual(len(params), 1)
self.assertEqual(1, len(params))
self.assertIn('MetricName', params[0])
self.assertIn('Unit', params[0])
self.assertIn('Value', params[0])
self.assertEqual(params[0]['MetricName'], 'foo')
self.assertEqual(params[0]['Unit'], 'Bytes')
self.assertEqual(params[0]['Value'], 234333)
self.assertEqual('foo', params[0]['MetricName'])
self.assertEqual('Bytes', params[0]['Unit'])
self.assertEqual(234333, params[0]['Value'])
def test_extract_param_list_garbage_prefix(self):
p = {'AMetricData.member.1.MetricName': 'foo',
'MetricData.member.1.Unit': 'Bytes',
'MetricData.member.1.Value': 234333}
params = api_utils.extract_param_list(p, prefix='MetricData')
self.assertEqual(len(params), 1)
self.assertEqual(1, len(params))
self.assertNotIn('MetricName', params[0])
self.assertIn('Unit', params[0])
self.assertIn('Value', params[0])
self.assertEqual(params[0]['Unit'], 'Bytes')
self.assertEqual(params[0]['Value'], 234333)
self.assertEqual('Bytes', params[0]['Unit'])
self.assertEqual(234333, params[0]['Value'])
def test_extract_param_list_garbage_prefix2(self):
p = {'AMetricData.member.1.MetricName': 'foo',
'BMetricData.member.1.Unit': 'Bytes',
'CMetricData.member.1.Value': 234333}
params = api_utils.extract_param_list(p, prefix='MetricData')
self.assertEqual(len(params), 0)
self.assertEqual(0, len(params))
def test_extract_param_list_garbage_suffix(self):
p = {'MetricData.member.1.AMetricName': 'foo',
'MetricData.member.1.Unit': 'Bytes',
'MetricData.member.1.Value': 234333}
params = api_utils.extract_param_list(p, prefix='MetricData')
self.assertEqual(len(params), 1)
self.assertEqual(1, len(params))
self.assertNotIn('MetricName', params[0])
self.assertIn('Unit', params[0])
self.assertIn('Value', params[0])
self.assertEqual(params[0]['Unit'], 'Bytes')
self.assertEqual(params[0]['Value'], 234333)
self.assertEqual('Bytes', params[0]['Unit'])
self.assertEqual(234333, params[0]['Value'])
def test_extract_param_list_multiple(self):
p = {'MetricData.member.1.MetricName': 'foo',
@ -131,15 +131,15 @@ class AWSCommonTest(HeatTestCase):
'MetricData.member.2.Unit': 'Bytes',
'MetricData.member.2.Value': 12345}
params = api_utils.extract_param_list(p, prefix='MetricData')
self.assertEqual(len(params), 2)
self.assertEqual(2, len(params))
self.assertIn('MetricName', params[0])
self.assertIn('MetricName', params[1])
self.assertEqual(params[0]['MetricName'], 'foo')
self.assertEqual(params[0]['Unit'], 'Bytes')
self.assertEqual(params[0]['Value'], 234333)
self.assertEqual(params[1]['MetricName'], 'foo2')
self.assertEqual(params[1]['Unit'], 'Bytes')
self.assertEqual(params[1]['Value'], 12345)
self.assertEqual('foo', params[0]['MetricName'])
self.assertEqual('Bytes', params[0]['Unit'])
self.assertEqual(234333, params[0]['Value'])
self.assertEqual('foo2', params[1]['MetricName'])
self.assertEqual('Bytes', params[1]['Unit'])
self.assertEqual(12345, params[1]['Value'])
def test_extract_param_list_multiple_missing(self):
# Handle case where there is an empty list item
@ -150,15 +150,15 @@ class AWSCommonTest(HeatTestCase):
'MetricData.member.3.Unit': 'Bytes',
'MetricData.member.3.Value': 12345}
params = api_utils.extract_param_list(p, prefix='MetricData')
self.assertEqual(len(params), 2)
self.assertEqual(2, len(params))
self.assertIn('MetricName', params[0])
self.assertIn('MetricName', params[1])
self.assertEqual(params[0]['MetricName'], 'foo')
self.assertEqual(params[0]['Unit'], 'Bytes')
self.assertEqual(params[0]['Value'], 234333)
self.assertEqual(params[1]['MetricName'], 'foo2')
self.assertEqual(params[1]['Unit'], 'Bytes')
self.assertEqual(params[1]['Value'], 12345)
self.assertEqual('foo', params[0]['MetricName'])
self.assertEqual('Bytes', params[0]['Unit'])
self.assertEqual(234333, params[0]['Value'])
self.assertEqual('foo2', params[1]['MetricName'])
self.assertEqual('Bytes', params[1]['Unit'])
self.assertEqual(12345, params[1]['Value'])
def test_extract_param_list_badindex(self):
p = {'MetricData.member.xyz.MetricName': 'foo',
@ -168,18 +168,18 @@ class AWSCommonTest(HeatTestCase):
'MetricData.member._3.Unit': 'Bytes',
'MetricData.member.-1000.Value': 12345}
params = api_utils.extract_param_list(p, prefix='MetricData')
self.assertEqual(len(params), 0)
self.assertEqual(0, len(params))
def test_reformat_dict_keys(self):
keymap = {"foo": "bar"}
data = {"foo": 123}
expected = {"bar": 123}
result = api_utils.reformat_dict_keys(keymap, data)
self.assertEqual(result, expected)
self.assertEqual(expected, result)
def test_reformat_dict_keys_missing(self):
keymap = {"foo": "bar", "foo2": "bar2"}
data = {"foo": 123}
expected = {"bar": 123}
result = api_utils.reformat_dict_keys(keymap, data)
self.assertEqual(result, expected)
self.assertEqual(expected, result)

@ -93,7 +93,7 @@ class CfnStackControllerTest(HeatTestCase):
})
expected = {'StackName': 'Foo',
'StackId': 'arn:openstack:heat::t:stacks/Foo/123'}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_enforce_ok(self):
params = {'Action': 'ListStacks'}
@ -155,7 +155,7 @@ class CfnStackControllerTest(HeatTestCase):
u'CreationTime': u'2012-07-09T09:12:45Z',
u'StackName': u'wordpress',
u'StackStatus': u'CREATE_COMPLETE'}]}}}
self.assertEqual(result, expected)
self.assertEqual(expected, result)
default_args = {'limit': None, 'sort_keys': None, 'marker': None,
'sort_dir': None, 'filters': None}
mock_call.assert_called_once_with(dummy_req.context, self.topic,
@ -292,7 +292,7 @@ class CfnStackControllerTest(HeatTestCase):
'DisableRollback': 'true',
'LastUpdatedTime': u'2012-07-09T09:13:11Z'}]}}}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_describe_arn(self):
# Format a dummy GET request to pass into the WSGI handler
@ -377,7 +377,7 @@ class CfnStackControllerTest(HeatTestCase):
'DisableRollback': 'true',
'LastUpdatedTime': u'2012-07-09T09:13:11Z'}]}}}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_describe_arn_invalidtenant(self):
# Format a dummy GET request to pass into the WSGI handler
@ -457,7 +457,7 @@ class CfnStackControllerTest(HeatTestCase):
dummy_req = self._dummy_GET_request(params)
result = self.controller._get_template(dummy_req)
expected = "abcdef"
self.assertEqual(result, expected)
self.assertEqual(expected, result)
# TODO(shardy) : test the _get_template TemplateUrl case
@ -506,7 +506,7 @@ class CfnStackControllerTest(HeatTestCase):
}
}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_create_rollback(self):
# Format a dummy request
@ -553,7 +553,7 @@ class CfnStackControllerTest(HeatTestCase):
}
}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_create_onfailure_true(self):
# Format a dummy request
@ -600,7 +600,7 @@ class CfnStackControllerTest(HeatTestCase):
}
}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_create_onfailure_false_delete(self):
# Format a dummy request
@ -647,7 +647,7 @@ class CfnStackControllerTest(HeatTestCase):
}
}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_create_onfailure_false_rollback(self):
# Format a dummy request
@ -694,7 +694,7 @@ class CfnStackControllerTest(HeatTestCase):
}
}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_create_onfailure_err(self):
# Format a dummy request
@ -925,7 +925,7 @@ class CfnStackControllerTest(HeatTestCase):
}
}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_update_bad_name(self):
stack_name = "wibble"
@ -989,7 +989,7 @@ class CfnStackControllerTest(HeatTestCase):
{'GetTemplateResult':
{'TemplateBody': template}}}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_get_template_err_rpcerr(self):
stack_name = "wordpress"
@ -1151,7 +1151,7 @@ class CfnStackControllerTest(HeatTestCase):
expected = {'DeleteStackResponse': {'DeleteStackResult': ''}}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_delete_err_rpcerr(self):
stack_name = "wordpress"
@ -1270,7 +1270,7 @@ class CfnStackControllerTest(HeatTestCase):
'ResourceStatusReason': u'state changed',
'LogicalResourceId': u'WikiDatabase'}]}}}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_events_list_err_rpcerr(self):
stack_name = "wordpress"
@ -1389,7 +1389,7 @@ class CfnStackControllerTest(HeatTestCase):
'Metadata': {u'wordpress': []},
'LogicalResourceId': u'WikiDatabase'}}}}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_describe_stack_resource_nonexistent_stack(self):
# Format a dummy request
@ -1515,7 +1515,7 @@ class CfnStackControllerTest(HeatTestCase):
u'a3455d8c-9f88-404d-a85b-5315293e67de',
'LogicalResourceId': u'WikiDatabase'}]}}}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_describe_stack_resources_bad_name(self):
stack_name = "wibble"
@ -1608,7 +1608,7 @@ class CfnStackControllerTest(HeatTestCase):
u'a3455d8c-9f88-404d-a85b-5315293e67de',
'LogicalResourceId': u'WikiDatabase'}]}}}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_describe_stack_resources_physical_not_found(self):
# Format a dummy request
@ -1705,7 +1705,7 @@ class CfnStackControllerTest(HeatTestCase):
u'a3455d8c-9f88-404d-a85b-5315293e67de',
'LogicalResourceId': u'WikiDatabase'}]}}}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
def test_list_stack_resources_bad_name(self):
stack_name = "wibble"

@ -45,31 +45,31 @@ class Ec2TokenTest(HeatTestCase):
def test_conf_get_paste(self):
dummy_conf = {'auth_uri': 'http://192.0.2.9/v2.0'}
ec2 = ec2token.EC2Token(app=None, conf=dummy_conf)
self.assertEqual(ec2._conf_get('auth_uri'), 'http://192.0.2.9/v2.0')
self.assertEqual('http://192.0.2.9/v2.0', ec2._conf_get('auth_uri'))
self.assertEqual(
ec2._conf_get_keystone_ec2_uri('http://192.0.2.9/v2.0'),
'http://192.0.2.9/v2.0/ec2tokens')
'http://192.0.2.9/v2.0/ec2tokens',
ec2._conf_get_keystone_ec2_uri('http://192.0.2.9/v2.0'))
def test_conf_get_opts(self):
cfg.CONF.set_default('auth_uri', 'http://192.0.2.9/v2.0/',
group='ec2authtoken')
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual(ec2._conf_get('auth_uri'), 'http://192.0.2.9/v2.0/')
self.assertEqual('http://192.0.2.9/v2.0/', ec2._conf_get('auth_uri'))
self.assertEqual(
ec2._conf_get_keystone_ec2_uri('http://192.0.2.9/v2.0/'),
'http://192.0.2.9/v2.0/ec2tokens')
'http://192.0.2.9/v2.0/ec2tokens',
ec2._conf_get_keystone_ec2_uri('http://192.0.2.9/v2.0/'))
def test_get_signature_param_old(self):
params = {'Signature': 'foo'}
dummy_req = self._dummy_GET_request(params)
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual(ec2._get_signature(dummy_req), 'foo')
self.assertEqual('foo', ec2._get_signature(dummy_req))
def test_get_signature_param_new(self):
params = {'X-Amz-Signature': 'foo'}
dummy_req = self._dummy_GET_request(params)
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual(ec2._get_signature(dummy_req), 'foo')
self.assertEqual('foo', ec2._get_signature(dummy_req))
def test_get_signature_header_space(self):
req_env = {'HTTP_AUTHORIZATION':
@ -78,7 +78,7 @@ class Ec2TokenTest(HeatTestCase):
'Signature=xyz')}
dummy_req = self._dummy_GET_request(environ=req_env)
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual(ec2._get_signature(dummy_req), 'xyz')
self.assertEqual('xyz', ec2._get_signature(dummy_req))
def test_get_signature_header_notlast(self):
req_env = {'HTTP_AUTHORIZATION':
@ -87,7 +87,7 @@ class Ec2TokenTest(HeatTestCase):
'SignedHeaders=content-type;host;x-amz-date ')}
dummy_req = self._dummy_GET_request(environ=req_env)
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual(ec2._get_signature(dummy_req), 'xyz')
self.assertEqual('xyz', ec2._get_signature(dummy_req))
def test_get_signature_header_nospace(self):
req_env = {'HTTP_AUTHORIZATION':
@ -96,19 +96,19 @@ class Ec2TokenTest(HeatTestCase):
'Signature=xyz')}
dummy_req = self._dummy_GET_request(environ=req_env)
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual(ec2._get_signature(dummy_req), 'xyz')
self.assertEqual('xyz', ec2._get_signature(dummy_req))
def test_get_access_param_old(self):
params = {'AWSAccessKeyId': 'foo'}
dummy_req = self._dummy_GET_request(params)
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual(ec2._get_access(dummy_req), 'foo')
self.assertEqual('foo', ec2._get_access(dummy_req))
def test_get_access_param_new(self):
params = {'X-Amz-Credential': 'foo/bar'}
dummy_req = self._dummy_GET_request(params)
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual(ec2._get_access(dummy_req), 'foo')
self.assertEqual('foo', ec2._get_access(dummy_req))
def test_get_access_header_space(self):
req_env = {'HTTP_AUTHORIZATION':
@ -117,7 +117,7 @@ class Ec2TokenTest(HeatTestCase):
'Signature=xyz')}
dummy_req = self._dummy_GET_request(environ=req_env)
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual(ec2._get_access(dummy_req), 'foo')
self.assertEqual('foo', ec2._get_access(dummy_req))
def test_get_access_header_nospace(self):
req_env = {'HTTP_AUTHORIZATION':
@ -126,7 +126,7 @@ class Ec2TokenTest(HeatTestCase):
'Signature=xyz')}
dummy_req = self._dummy_GET_request(environ=req_env)
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual(ec2._get_access(dummy_req), 'foo')
self.assertEqual('foo', ec2._get_access(dummy_req))
def test_get_access_header_last(self):
req_env = {'HTTP_AUTHORIZATION':
@ -135,13 +135,13 @@ class Ec2TokenTest(HeatTestCase):
'Signature=xyz,Credential=foo/bar')}
dummy_req = self._dummy_GET_request(environ=req_env)
ec2 = ec2token.EC2Token(app=None, conf={})
self.assertEqual(ec2._get_access(dummy_req), 'foo')
self.assertEqual('foo', ec2._get_access(dummy_req))
def test_call_x_auth_user(self):
req_env = {'HTTP_X_AUTH_USER': 'foo'}
dummy_req = self._dummy_GET_request(environ=req_env)
ec2 = ec2token.EC2Token(app='xyz', conf={})
self.assertEqual(ec2.__call__(dummy_req), 'xyz')
self.assertEqual('xyz', ec2.__call__(dummy_req))
def test_call_auth_nosig(self):
req_env = {'HTTP_AUTHORIZATION':
@ -179,7 +179,7 @@ class Ec2TokenTest(HeatTestCase):
'Signature=xyz')}
dummy_req = self._dummy_GET_request(environ=req_env)
ec2 = ec2token.EC2Token(app='xyz', conf={})
self.assertEqual(ec2.__call__(dummy_req), 'xyz')
self.assertEqual('xyz', ec2.__call__(dummy_req))
def _stub_http_connection(self, headers={}, params={}, response=None,
req_url='http://123:5000/v2.0/ec2tokens'):
@ -224,7 +224,7 @@ class Ec2TokenTest(HeatTestCase):
self._stub_http_connection(headers={'Authorization': auth_str},
response=ok_resp)
self.m.ReplayAll()
self.assertEqual(ec2.__call__(dummy_req), 'woot')
self.assertEqual('woot', ec2.__call__(dummy_req))
self.assertEqual('tenant', dummy_req.headers['X-Tenant-Name'])
self.assertEqual('abcd1234', dummy_req.headers['X-Tenant-Id'])
@ -252,7 +252,7 @@ class Ec2TokenTest(HeatTestCase):
self._stub_http_connection(headers={'Authorization': auth_str},
response=ok_resp)
self.m.ReplayAll()
self.assertEqual(ec2.__call__(dummy_req), 'woot')
self.assertEqual('woot', ec2.__call__(dummy_req))
self.assertEqual('aa,bb,cc', dummy_req.headers['X-Roles'])
self.m.VerifyAll()
@ -340,7 +340,7 @@ class Ec2TokenTest(HeatTestCase):
self._stub_http_connection(response=ok_resp,
params={'AWSAccessKeyId': 'foo'})
self.m.ReplayAll()
self.assertEqual(ec2.__call__(dummy_req), 'woot')
self.assertEqual('woot', ec2.__call__(dummy_req))
self.m.VerifyAll()
@ -376,7 +376,7 @@ class Ec2TokenTest(HeatTestCase):
params={'AWSAccessKeyId': 'foo'})
self.m.ReplayAll()
self.assertEqual(ec2.__call__(dummy_req), 'woot')
self.assertEqual('woot', ec2.__call__(dummy_req))
self.m.VerifyAll()
@ -446,7 +446,7 @@ class Ec2TokenTest(HeatTestCase):
self.m.ReplayAll()
ex = self.assertRaises(exception.HeatInternalFailureError,
ec2.__call__, dummy_req)
self.assertEqual(str(ex), 'Service misconfigured')
self.assertEqual('Service misconfigured', str(ex))
self.m.VerifyAll()
@ -467,7 +467,7 @@ class Ec2TokenTest(HeatTestCase):
self._stub_http_connection(response=ok_resp,
params={'AWSAccessKeyId': 'foo'})
self.m.ReplayAll()
self.assertEqual(ec2.__call__(dummy_req), 'woot')
self.assertEqual('woot', ec2.__call__(dummy_req))
self.m.VerifyAll()
@ -490,6 +490,6 @@ class Ec2TokenTest(HeatTestCase):
self._stub_http_connection(response=ok_resp,
params={'AWSAccessKeyId': 'foo'})
self.m.ReplayAll()
self.assertEqual(ec2.__call__(dummy_req), 'woot')
self.assertEqual('woot', ec2.__call__(dummy_req))
self.m.VerifyAll()

@ -67,7 +67,7 @@ class InstantiationDataTest(HeatTestCase):
data = {"key1": ["val1[0]", "val1[1]"], "key2": "val2"}
json_repr = '{ "key1": [ "val1[0]", "val1[1]" ], "key2": "val2" }'
parsed = stacks.InstantiationData.format_parse(json_repr, 'foo')
self.assertEqual(parsed, data)
self.assertEqual(data, parsed)
def test_format_parse_invalid(self):
self.assertRaises(webob.exc.HTTPBadRequest,
@ -91,7 +91,7 @@ parameters:
def test_stack_name(self):
body = {'stack_name': 'wibble'}
data = stacks.InstantiationData(body)
self.assertEqual(data.stack_name(), 'wibble')
self.assertEqual('wibble', data.stack_name())
def test_stack_name_missing(self):
body = {'not the stack_name': 'wibble'}
@ -102,13 +102,13 @@ parameters:
template = {'foo': 'bar', 'blarg': 'wibble'}
body = {'template': template}
data = stacks.InstantiationData(body)
self.assertEqual(data.template(), template)
self.assertEqual(template, data.template())
def test_template_string_json(self):
template = '{"foo": "bar", "blarg": "wibble"}'
body = {'template': template}
data = stacks.InstantiationData(body)
self.assertEqual(data.template(), json.loads(template))
self.assertEqual(json.loads(template), data.template())
def test_template_string_yaml(self):
template = '''foo: bar
@ -124,7 +124,7 @@ blarg: wibble
body = {'template': template}
data = stacks.InstantiationData(body)
self.assertEqual(data.template(), parsed)
self.assertEqual(parsed, data.template())
def test_template_url(self):
template = {'foo': 'bar', 'blarg': 'wibble'}
@ -136,7 +136,7 @@ blarg: wibble
urlfetch.get(url).AndReturn(json.dumps(template))
self.m.ReplayAll()
self.assertEqual(data.template(), template)
self.assertEqual(template, data.template())
self.m.VerifyAll()
def test_template_priority(self):
@ -148,7 +148,7 @@ blarg: wibble
self.m.StubOutWithMock(urlfetch, 'get')
self.m.ReplayAll()
self.assertEqual(data.template(), template)
self.assertEqual(template, data.template())
self.m.VerifyAll()
def test_template_missing(self):
@ -162,13 +162,13 @@ blarg: wibble
body = {'parameters': params,
'resource_registry': {}}
data = stacks.InstantiationData(body)
self.assertEqual(data.environment(), body)
self.assertEqual(body, data.environment())
def test_environment_only_params(self):
env = {'parameters': {'foo': 'bar', 'blarg': 'wibble'}}
body = {'environment': env}
data = stacks.InstantiationData(body)
self.assertEqual(data.environment(), env)
self.assertEqual(env, data.environment())
def test_environment_and_parameters(self):
body = {'parameters': {'foo': 'bar'},
@ -177,7 +177,7 @@ blarg: wibble
'foo': 'bar'},
'resource_registry': {}}
data = stacks.InstantiationData(body)
self.assertEqual(data.environment(), expect)
self.assertEqual(expect, data.environment())
def test_parameters_override_environment(self):
# This tests that the cli parameters will override
@ -191,7 +191,7 @@ blarg: wibble
'tester': 'Yes'},
'resource_registry': {}}
data = stacks.InstantiationData(body)
self.assertEqual(data.environment(), expect)
self.assertEqual(expect, data.environment())
def test_environment_bad_format(self):
env = {'somethingnotsupported': {'blarg': 'wibble'}}
@ -203,9 +203,8 @@ blarg: wibble
env = {'foo': 'bar', 'blarg': 'wibble'}
body = {'not the environment': env}
data = stacks.InstantiationData(body)
self.assertEqual(data.environment(),
{'parameters': {},
'resource_registry': {}})
self.assertEqual({'parameters': {}, 'resource_registry': {}},
data.environment())
def test_args(self):
body = {
@ -217,7 +216,7 @@ blarg: wibble
'timeout_mins': 60,
}
data = stacks.InstantiationData(body)
self.assertEqual(data.args(), {'timeout_mins': 60})
self.assertEqual({'timeout_mins': 60}, data.args())
class ControllerTest(object):
@ -369,14 +368,14 @@ class StackControllerTest(ControllerTest, HeatTestCase):
}
]
}
self.assertEqual(result, expected)
self.assertEqual(expected, result)
default_args = {'limit': None, 'sort_keys': None, 'marker': None,
'sort_dir': None, 'filters': {}}
mock_call.assert_called_once_with(req.context, self.topic,
{'namespace': None,
'method': 'list_stacks',
'args': default_args,
'version': self.api_version},
'method': 'list_stacks',
'args': default_args,
'version': self.api_version},
None)
@mock.patch.object(rpc, 'call')
@ -521,14 +520,14 @@ class StackControllerTest(ControllerTest, HeatTestCase):
]
}
self.assertEqual(result, expected)
self.assertEqual(expected, result)
default_args = {'limit': None, 'sort_keys': None, 'marker': None,
'sort_dir': None, 'filters': None}
mock_call.assert_called_once_with(req.context, self.topic,
{'namespace': None,
'method': 'list_stacks',
'args': default_args,
'version': self.api_version},
'method': 'list_stacks',
'args': default_args,
'version': self.api_version},
None)
@mock.patch.object(rpc, 'call')
@ -542,13 +541,13 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self.controller.index,
req, tenant_id=self.tenant)
self.assertEqual(resp.json['code'], 400)
self.assertEqual(resp.json['error']['type'], 'AttributeError')
self.assertEqual(400, resp.json['code'])
self.assertEqual('AttributeError', resp.json['error']['type'])
mock_call.assert_called_once_with(req.context, self.topic,
{'namespace': None,
'method': 'list_stacks',
'args': mock.ANY,
'version': self.api_version},
'method': 'list_stacks',
'args': mock.ANY,
'version': self.api_version},
None)
def test_index_err_denied_policy(self, mock_enforce):
@ -574,13 +573,13 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self.controller.index,
req, tenant_id=self.tenant)
self.assertEqual(resp.json['code'], 500)
self.assertEqual(resp.json['error']['type'], 'Exception')
self.assertEqual(500, resp.json['code'])
self.assertEqual('Exception', resp.json['error']['type'])
mock_call.assert_called_once_with(req.context, self.topic,
{'namespace': None,
'method': 'list_stacks',
'args': mock.ANY,
'version': self.api_version},
'method': 'list_stacks',
'args': mock.ANY,
'version': self.api_version},
None)
def test_create(self, mock_enforce):
@ -616,7 +615,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
expected = {'stack':
{'id': '1',
'links': [{'href': self._url(identity), 'rel': 'self'}]}}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
self.m.VerifyAll()
@ -653,7 +652,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
expected = {'stack':
{'id': '1',
'links': [{'href': self._url(identity), 'rel': 'self'}]}}
self.assertEqual(result, expected)
self.assertEqual(expected, result)
self.m.VerifyAll()
@ -710,22 +709,22 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self.controller.create,
req, tenant_id=self.tenant, body=body)
self.assertEqual(resp.json['code'], 400)
self.assertEqual(resp.json['error']['type'], 'AttributeError')
self.assertEqual(400, resp.json['code'])
self.assertEqual('AttributeError', resp.json['error']['type'])
resp = request_with_middleware(fault.FaultWrapper,
self.controller.create,
req, tenant_id=self.tenant, body=body)
self.assertEqual(resp.json['code'], 400)
self.assertEqual(resp.json['error']['type'], 'UnknownUserParameter')
self.assertEqual(400, resp.json['code'])
self.assertEqual('UnknownUserParameter', resp.json['error']['type'])
resp = request_with_middleware(fault.FaultWrapper,
self.controller.create,
req, tenant_id=self.tenant, body=body)
self.assertEqual(resp.json['code'], 400)
self.assertEqual(resp.json['error']['type'], 'UserParameterMissing')
self.assertEqual(400, resp.json['code'])
self.assertEqual('UserParameterMissing', resp.json['error']['type'])
self.m.VerifyAll()
def test_create_err_existing(self, mock_enforce):
@ -759,8 +758,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self.controller.create,
req, tenant_id=self.tenant, body=body)
self.assertEqual(resp.json['code'], 409)
self.assertEqual(resp.json['error']['type'], 'StackExists')
self.assertEqual(409, resp.json['code'])
self.assertEqual('StackExists', resp.json['error']['type'])
self.m.VerifyAll()
def test_create_err_denied_policy(self, mock_enforce):
@ -813,8 +812,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self.controller.create,
req, tenant_id=self.tenant, body=body)
self.assertEqual(resp.json['code'], 400)
self.assertEqual(resp.json['error']['type'], 'StackValidationFailed')
self.assertEqual(400, resp.json['code'])
self.assertEqual('StackValidationFailed', resp.json['error']['type'])
self.m.VerifyAll()
def test_create_err_stack_bad_reqest(self, mock_enforce):
@ -835,8 +834,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
# When HTTP disguised exceptions reach the fault app, they are
# converted into regular responses, just like non-HTTP exceptions
self.assertEqual(resp.json['code'], 400)
self.assertEqual(resp.json['error']['type'], 'HTTPBadRequest')
self.assertEqual(400, resp.json['code'])
self.assertEqual('HTTPBadRequest', resp.json['error']['type'])
self.assertIsNotNone(resp.json['error']['traceback'])
def test_lookup(self, mock_enforce):
@ -858,7 +857,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
found = self.assertRaises(
webob.exc.HTTPFound, self.controller.lookup, req,
tenant_id=identity.tenant, stack_name=identity.stack_name)
self.assertEqual(found.location, self._url(identity))
self.assertEqual(self._url(identity), found.location)
self.m.VerifyAll()
@ -873,7 +872,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
found = self.assertRaises(
webob.exc.HTTPFound, self.controller.lookup,
req, tenant_id=identity.tenant, stack_name=identity.arn())
self.assertEqual(found.location, self._url(identity))
self.assertEqual(self._url(identity), found.location)
self.m.VerifyAll()
@ -899,8 +898,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
req, tenant_id=self.tenant,
stack_name=stack_name)
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'StackNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('StackNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_lookup_err_policy(self, mock_enforce):
@ -933,12 +932,14 @@ class StackControllerTest(ControllerTest, HeatTestCase):
None).AndReturn(identity)
self.m.ReplayAll()
found = self.assertRaises(
webob.exc.HTTPFound, self.controller.lookup, req,
tenant_id=identity.tenant, stack_name=identity.stack_name,
path='resources')
self.assertEqual(found.location,
self._url(identity) + '/resources')
self.assertEqual(self._url(identity) + '/resources',
found.location)
self.m.VerifyAll()
def test_lookup_resource_nonexistent(self, mock_enforce):
@ -964,8 +965,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
stack_name=stack_name,
path='resources')
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'StackNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('StackNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_lookup_resource_err_denied_policy(self, mock_enforce):
@ -1051,7 +1052,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
u'timeout_mins': 60,
}
}
self.assertEqual(response, expected)
self.assertEqual(expected, response)
self.m.VerifyAll()
def test_show_notfound(self, mock_enforce):
@ -1076,8 +1077,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
stack_name=identity.stack_name,
stack_id=identity.stack_id)
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'StackNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('StackNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_show_invalidtenant(self, mock_enforce):
@ -1093,7 +1094,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
stack_name=identity.stack_name,
stack_id=identity.stack_id)
self.assertEqual(resp.status_int, 403)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', str(resp))
self.m.VerifyAll()
@ -1131,7 +1132,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
stack_name=identity.stack_name,
stack_id=identity.stack_id)
self.assertEqual(response, template)
self.assertEqual(template, response)
self.m.VerifyAll()
def test_get_template_err_denied_policy(self, mock_enforce):
@ -1173,8 +1174,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
stack_name=identity.stack_name,
stack_id=identity.stack_id)
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'StackNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('StackNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_update(self, mock_enforce):
@ -1247,8 +1248,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
stack_id=identity.stack_id,
body=body)
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'StackNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('StackNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_update_err_denied_policy(self, mock_enforce):
@ -1373,8 +1374,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
stack_name=identity.stack_name,
stack_id=identity.stack_id)
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'StackNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('StackNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_validate_template(self, mock_enforce):
@ -1407,7 +1408,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
response = self.controller.validate_template(req,
tenant_id=self.tenant,
body=body)
self.assertEqual(response, engine_response)
self.assertEqual(engine_response, response)
self.m.VerifyAll()
def test_validate_template_error(self, mock_enforce):
@ -1464,7 +1465,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self.m.ReplayAll()
response = self.controller.list_resource_types(req,
tenant_id=self.tenant)
self.assertEqual(response, {'resource_types': engine_response})
self.assertEqual({'resource_types': engine_response}, response)
self.m.VerifyAll()
def test_list_resource_types_error(self, mock_enforce):
@ -1484,8 +1485,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
resp = request_with_middleware(fault.FaultWrapper,
self.controller.list_resource_types,
req, tenant_id=self.tenant)
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'ResourceTypeNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('ResourceTypeNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_list_resource_types_err_denied_policy(self, mock_enforce):
@ -1524,7 +1525,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
response = self.controller.resource_schema(req,
tenant_id=self.tenant,
type_name=type_name)
self.assertEqual(response, engine_response)
self.assertEqual(engine_response, response)
self.m.VerifyAll()
def test_resource_schema_nonexist(self, mock_enforce):
@ -1546,8 +1547,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self.controller.resource_schema,
req, tenant_id=self.tenant,
type_name=type_name)
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'ResourceTypeNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('ResourceTypeNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_resource_schema_err_denied_policy(self, mock_enforce):
@ -1597,8 +1598,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
self.controller.generate_template,
req, tenant_id=self.tenant,
type_name='NOT_FOUND')
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'ResourceTypeNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('ResourceTypeNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_generate_template_err_denied_policy(self, mock_enforce):
@ -1625,9 +1626,9 @@ class StackSerializerTest(HeatTestCase):
'links': [{'href': 'location', "rel": "self"}]}}
response = webob.Response()
response = self.serializer.create(response, result)
self.assertEqual(response.status_int, 201)
self.assertEqual(response.headers['Location'], 'location')
self.assertEqual(response.headers['Content-Type'], 'application/json')
self.assertEqual(201, response.status_int)
self.assertEqual('location', response.headers['Location'])
self.assertEqual('application/json', response.headers['Content-Type'])
@mock.patch.object(policy.Enforcer, 'enforce')
@ -1699,7 +1700,7 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
u'a3455d8c-9f88-404d-a85b-5315293e67de',
u'resource_type': u'AWS::EC2::Instance'}]}
self.assertEqual(result, expected)
self.assertEqual(expected, result)
self.m.VerifyAll()
def test_index_nonexist(self, mock_enforce):
@ -1725,8 +1726,8 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
stack_name=stack_identity.stack_name,
stack_id=stack_identity.stack_id)
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'StackNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('StackNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_index_denied_policy(self, mock_enforce):
@ -1805,7 +1806,7 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
}
}
self.assertEqual(result, expected)
self.assertEqual(expected, result)
self.m.VerifyAll()
def test_show_nonexist(self, mock_enforce):
@ -1836,8 +1837,8 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
stack_id=stack_identity.stack_id,
resource_name=res_name)
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'StackNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('StackNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_show_nonexist_resource(self, mock_enforce):
@ -1868,8 +1869,8 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
stack_id=stack_identity.stack_id,
resource_name=res_name)
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'ResourceNotFound')
self.assertEqual(404, resp.json['code'])
self.assertEqual('ResourceNotFound', resp.json['error']['type'])
self.m.VerifyAll()
def test_show_uncreated_resource(self, mock_enforce):
@ -1900,8 +1901,8 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
stack_id=stack_identity.stack_id,
resource_name=res_name)
self.assertEqual(resp.json['code'], 404)
self.assertEqual(resp.json['error']['type'], 'ResourceNotAvailable')
self.assertEqual(404, resp.json['code'])
self.assertEqual('ResourceNotAvailable', resp.json['error']['type'])
self.m.VerifyAll()
def test_show_err_denied_policy(self, mock_enforce):
@ -1965,7 +1966,7 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):