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

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

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

This patch includes the other half of the files touched by these changes
(starting from test_n* plus contrib code) to ease the review.

Change-Id: I870386871581980abd796304dd91be0c662cb73e
Partial-Bug: #1259292
changes/15/64415/6
Pavlo Shchelokovskyy 9 years ago
parent 834eb42e2e
commit 240fec9eef
  1. 16
      contrib/docker-plugin/tests/test_docker_container.py
  2. 73
      contrib/rackspace/heat/tests/test_auto_scale.py
  3. 15
      contrib/rackspace/heat/tests/test_cloud_loadbalancer.py
  4. 6
      contrib/rackspace/heat/tests/test_clouddatabase.py
  5. 44
      contrib/rackspace/heat/tests/test_rackspace_cloud_server.py
  6. 18
      heat/tests/test_nested_stack.py
  7. 8
      heat/tests/test_neutron_autoscaling.py
  8. 29
      heat/tests/test_notifications.py
  9. 6
      heat/tests/test_nova_keypair.py
  10. 54
      heat/tests/test_parameters.py
  11. 498
      heat/tests/test_parser.py
  12. 12
      heat/tests/test_plugin_loader.py
  13. 55
      heat/tests/test_properties.py
  14. 6
      heat/tests/test_provider_template.py
  15. 68
      heat/tests/test_resource.py
  16. 2
      heat/tests/test_rpc_client.py
  17. 20
      heat/tests/test_scheduler.py
  18. 68
      heat/tests/test_server.py
  19. 4
      heat/tests/test_server_tags.py
  20. 30
      heat/tests/test_short_id.py
  21. 16
      heat/tests/test_signal.py
  22. 28
      heat/tests/test_sqlalchemy_api.py
  23. 8
      heat/tests/test_stack_resource.py
  24. 4
      heat/tests/test_urlfetch.py
  25. 4
      heat/tests/test_user.py
  26. 23
      heat/tests/test_validate.py
  27. 36
      heat/tests/test_volume.py
  28. 4
      heat/tests/test_vpc.py
  29. 62
      heat/tests/test_waitcondition.py
  30. 104
      heat/tests/test_watch.py
  31. 48
      heat/tests/test_wsgi.py

@ -64,8 +64,8 @@ class DockerContainerTest(HeatTestCase):
self.assertIsNone(resource.validate())
self.m.ReplayAll()
scheduler.TaskRunner(resource.create)()
self.assertEqual(resource.state, (resource.CREATE,
resource.COMPLETE))
self.assertEqual((resource.CREATE, resource.COMPLETE),
resource.state)
return resource
def get_container_state(self, resource):
@ -96,8 +96,8 @@ class DockerContainerTest(HeatTestCase):
def test_resource_delete(self):
container = self.create_container('Blog')
scheduler.TaskRunner(container.delete)()
self.assertEqual(container.state, (container.DELETE,
container.COMPLETE))
self.assertEqual((container.DELETE, container.COMPLETE),
container.state)
running = self.get_container_state(container)['Running']
self.assertIs(False, running)
self.m.VerifyAll()
@ -106,14 +106,14 @@ class DockerContainerTest(HeatTestCase):
container = self.create_container('Blog')
# Test suspend
scheduler.TaskRunner(container.suspend)()
self.assertEqual(container.state, (container.SUSPEND,
container.COMPLETE))
self.assertEqual((container.SUSPEND, container.COMPLETE),
container.state)
running = self.get_container_state(container)['Running']
self.assertIs(False, running)
# Test resume
scheduler.TaskRunner(container.resume)()
self.assertEqual(container.state, (container.RESUME,
container.COMPLETE))
self.assertEqual((container.RESUME, container.COMPLETE),
container.state)
running = self.get_container_state(container)['Running']
self.assertIs(True, running)
self.m.VerifyAll()

@ -207,7 +207,7 @@ class ScalingGroupTest(HeatTestCase):
self.stack = utils.parse_stack(self.group_template)
self.stack.create()
self.assertEqual(
self.stack.state, ('CREATE', 'COMPLETE'),
('CREATE', 'COMPLETE'), self.stack.state,
self.stack.status_reason)
def test_group_create(self):
@ -216,9 +216,8 @@ class ScalingGroupTest(HeatTestCase):
the group ID as the resource ID.
"""
self._setup_test_stack()
self.assertEqual(len(self.fake_auto_scale.groups), 1)
self.assertEqual(1, len(self.fake_auto_scale.groups))
self.assertEqual(
self.fake_auto_scale.groups['0'].kwargs,
{
'cooldown': 60,
'disk_config': None,
@ -234,9 +233,11 @@ class ScalingGroupTest(HeatTestCase):
'name': 'My Group',
'networks': None,
'personality': None,
'server_name': u'autoscaled-server'})
'server_name': u'autoscaled-server'},
self.fake_auto_scale.groups['0'].kwargs)
resource = self.stack['my_group']
self.assertEqual(resource.FnGetRefId(), '0')
self.assertEqual('0', resource.FnGetRefId())
def test_update_group_config(self):
"""
@ -250,9 +251,9 @@ class ScalingGroupTest(HeatTestCase):
new_template['Properties']['groupConfiguration']['minEntities'] = 5
scheduler.TaskRunner(resource.update, new_template)()
self.assertEqual(len(self.fake_auto_scale.groups), 1)
self.assertEqual(1, len(self.fake_auto_scale.groups))
self.assertEqual(
self.fake_auto_scale.groups['0'].kwargs['min_entities'], 5)
5, self.fake_auto_scale.groups['0'].kwargs['min_entities'])
def test_update_launch_config(self):
"""
@ -267,10 +268,10 @@ class ScalingGroupTest(HeatTestCase):
lcargs['loadBalancers'] = [{'loadBalancerId': '1', 'port': 80}]
scheduler.TaskRunner(resource.update, new_template)()
self.assertEqual(len(self.fake_auto_scale.groups), 1)
self.assertEqual(1, len(self.fake_auto_scale.groups))
self.assertEqual(
self.fake_auto_scale.groups['0'].kwargs['load_balancers'],
[{'loadBalancerId': 1, 'port': 80}])
[{'loadBalancerId': 1, 'port': 80}],
self.fake_auto_scale.groups['0'].kwargs['load_balancers'])
def test_delete(self):
"""
@ -279,7 +280,7 @@ class ScalingGroupTest(HeatTestCase):
self._setup_test_stack()
resource = self.stack['my_group']
scheduler.TaskRunner(resource.delete)()
self.assertEqual(self.fake_auto_scale.groups, {})
self.assertEqual({}, self.fake_auto_scale.groups)
def test_delete_without_backing_group(self):
"""
@ -290,7 +291,7 @@ class ScalingGroupTest(HeatTestCase):
resource = self.stack['my_group']
del self.fake_auto_scale.groups['0']
scheduler.TaskRunner(resource.delete)()
self.assertEqual(self.fake_auto_scale.groups, {})
self.assertEqual({}, self.fake_auto_scale.groups)
def test_delete_waits_for_server_deletion(self):
"""
@ -309,7 +310,7 @@ class ScalingGroupTest(HeatTestCase):
resource = self.stack['my_group']
scheduler.TaskRunner(resource.delete)()
# It really called delete until it succeeded:
self.assertEqual(delete_counter.next(), 4)
self.assertEqual(4, delete_counter.next())
def test_delete_blows_up_on_other_errors(self):
"""
@ -356,7 +357,7 @@ class PolicyTest(HeatTestCase):
self.stack = utils.parse_stack(template)
self.stack.create()
self.assertEqual(
self.stack.state, ('CREATE', 'COMPLETE'),
('CREATE', 'COMPLETE'), self.stack.state,
self.stack.status_reason)
def test_create_webhook_change(self):
@ -366,15 +367,15 @@ class PolicyTest(HeatTestCase):
"""
self._setup_test_stack(self.policy_template)
resource = self.stack['my_policy']
self.assertEqual(resource.FnGetRefId(), 'my-group-id:0')
self.assertEqual('my-group-id:0', resource.FnGetRefId())
self.assertEqual(
self.fake_auto_scale.policies['0'].kwargs,
{
'name': '+10 on webhook',
'scaling_group': 'my-group-id',
'change': 10,
'cooldown': 0,
'policy_type': 'webhook'})
'policy_type': 'webhook'},
self.fake_auto_scale.policies['0'].kwargs)
def test_webhook_change_percent(self):
"""
@ -386,14 +387,14 @@ class PolicyTest(HeatTestCase):
del template['Resources']['my_policy']['Properties']['change']
self._setup_test_stack(template)
self.assertEqual(
self.fake_auto_scale.policies['0'].kwargs,
{
'name': '+10 on webhook',
'scaling_group': 'my-group-id',
'change': 10,
'is_percent': True,
'cooldown': 0,
'policy_type': 'webhook'})
'policy_type': 'webhook'},
self.fake_auto_scale.policies['0'].kwargs)
def test_webhook_desired_capacity(self):
"""
@ -405,13 +406,13 @@ class PolicyTest(HeatTestCase):
del template['Resources']['my_policy']['Properties']['change']
self._setup_test_stack(template)
self.assertEqual(
self.fake_auto_scale.policies['0'].kwargs,
{
'name': '+10 on webhook',
'scaling_group': 'my-group-id',
'desired_capacity': 1,
'cooldown': 0,
'policy_type': 'webhook'})
'policy_type': 'webhook'},
self.fake_auto_scale.policies['0'].kwargs)
def test_schedule(self):
"""We can specify schedule-type policies with args."""
@ -421,14 +422,14 @@ class PolicyTest(HeatTestCase):
props['args'] = {'cron': '0 0 0 * *'}
self._setup_test_stack(template)
self.assertEqual(
self.fake_auto_scale.policies['0'].kwargs,
{
'name': '+10 on webhook',
'scaling_group': 'my-group-id',
'change': 10,
'cooldown': 0,
'policy_type': 'schedule',
'args': {'cron': '0 0 0 * *'}})
'args': {'cron': '0 0 0 * *'}},
self.fake_auto_scale.policies['0'].kwargs)
def test_update(self):
"""
@ -442,21 +443,21 @@ class PolicyTest(HeatTestCase):
scheduler.TaskRunner(resource.update, template)()
self.assertEqual(
self.fake_auto_scale.policies['0'].kwargs,
{
'name': '+10 on webhook',
'scaling_group': 'my-group-id',
'change': 50,
'is_percent': True,
'cooldown': 0,
'policy_type': 'webhook'})
'policy_type': 'webhook'},
self.fake_auto_scale.policies['0'].kwargs)
def test_delete(self):
"""Deleting the resource deletes the policy with pyrax."""
self._setup_test_stack(self.policy_template)
resource = self.stack['my_policy']
scheduler.TaskRunner(resource.delete)()
self.assertEqual(self.fake_auto_scale.policies, {})
self.assertEqual({}, self.fake_auto_scale.policies)
def test_delete_policy_non_existent(self):
"""
@ -467,7 +468,7 @@ class PolicyTest(HeatTestCase):
resource = self.stack['my_policy']
del self.fake_auto_scale.policies['0']
scheduler.TaskRunner(resource.delete)()
self.assertEqual(self.fake_auto_scale.policies, {})
self.assertEqual({}, self.fake_auto_scale.policies)
class WebHookTest(HeatTestCase):
@ -497,7 +498,7 @@ class WebHookTest(HeatTestCase):
self.stack = utils.parse_stack(template)
self.stack.create()
self.assertEqual(
self.stack.state, ('CREATE', 'COMPLETE'),
('CREATE', 'COMPLETE'), self.stack.state,
self.stack.status_reason)
def test_create(self):
@ -505,14 +506,14 @@ class WebHookTest(HeatTestCase):
self._setup_test_stack(self.webhook_template)
resource = self.stack['my_webhook']
self.assertEqual(
self.fake_auto_scale.webhooks['0'].kwargs,
{
'name': 'exec my policy',
'scaling_group': 'my-group-id',
'policy': 'my-policy-id',
'metadata': {'a': 'b'}})
self.assertEqual(resource.FnGetAtt("executeUrl"), "self-url")
self.assertEqual(resource.FnGetAtt("capabilityUrl"), "capability-url")
'metadata': {'a': 'b'}},
self.fake_auto_scale.webhooks['0'].kwargs)
self.assertEqual("self-url", resource.FnGetAtt("executeUrl"))
self.assertEqual("capability-url", resource.FnGetAtt("capabilityUrl"))
def test_failed_create(self):
"""When a create fails, getting the attributes returns None."""
@ -532,19 +533,19 @@ class WebHookTest(HeatTestCase):
scheduler.TaskRunner(resource.update, template)()
self.assertEqual(
self.fake_auto_scale.webhooks['0'].kwargs,
{
'name': 'newhook',
'scaling_group': 'my-group-id',
'policy': 'my-policy-id',
'metadata': {'a': 'different!'}})
'metadata': {'a': 'different!'}},
self.fake_auto_scale.webhooks['0'].kwargs)
def test_delete(self):
"""Deleting the resource deletes the webhook with pyrax."""
self._setup_test_stack(self.webhook_template)
resource = self.stack['my_webhook']
scheduler.TaskRunner(resource.delete)()
self.assertEqual(self.fake_auto_scale.webhooks, {})
self.assertEqual({}, self.fake_auto_scale.webhooks)
def test_delete_without_backing_webhook(self):
"""
@ -555,4 +556,4 @@ class WebHookTest(HeatTestCase):
resource = self.stack['my_webhook']
del self.fake_auto_scale.webhooks['0']
scheduler.TaskRunner(resource.delete)()
self.assertEqual(self.fake_auto_scale.webhooks, {})
self.assertEqual({}, self.fake_auto_scale.webhooks)

@ -298,10 +298,11 @@ class LoadBalancerTest(HeatTestCase):
rsrc, fake_loadbalancer = self._mock_loadbalancer(template,
self.lb_name,
expected)
self.assertEqual(rsrc.validate(), {
'Error':
'The halfClosed property is only available for the '
'TCP or TCP_CLIENT_FIRST protocols'})
self.assertEqual(
{'Error':
'The halfClosed property is only available for the '
'TCP or TCP_CLIENT_FIRST protocols'},
rsrc.validate())
#test TCP protocol
template = self._set_template(template, protocol='TCP')
@ -349,8 +350,8 @@ class LoadBalancerTest(HeatTestCase):
rsrc, fake_loadbalancer = self._mock_loadbalancer(template,
self.lb_name,
expected)
self.assertEqual(rsrc.validate(),
{'Error': 'Unknown Property bodyRegex'})
self.assertEqual({'Error': 'Unknown Property bodyRegex'},
rsrc.validate())
#test http fields
health_monitor['type'] = 'HTTP'
@ -425,7 +426,7 @@ class LoadBalancerTest(HeatTestCase):
scheduler.TaskRunner(rsrc.create)()
self.m.VerifyAll()
self.assertEqual(rsrc.FnGetRefId(), rsrc.resource_id)
self.assertEqual(rsrc.resource_id, rsrc.FnGetRefId())
def test_post_creation_error_page(self):
error_page = "REALLY BIG ERROR"

@ -137,9 +137,9 @@ class CloudDBInstanceTest(HeatTestCase):
instance.handle_create()
expected_hostname = fakedbinstance.hostname
expected_href = fakedbinstance.links[0]['href']
self.assertEqual(instance._resolve_attribute('hostname'),
expected_hostname)
self.assertEqual(instance._resolve_attribute('href'), expected_href)
self.assertEqual(expected_hostname,
instance._resolve_attribute('hostname'))
self.assertEqual(expected_href, instance._resolve_attribute('href'))
self.m.VerifyAll()
def test_clouddbinstance_delete_resource_notfound(self):

@ -181,10 +181,10 @@ class RackspaceCloudServerTest(HeatTestCase):
expected_public = return_server.networks['public'][0]
expected_private = return_server.networks['private'][0]
self.assertEqual(cs.FnGetAtt('PublicIp'), expected_public)
self.assertEqual(cs.FnGetAtt('PrivateIp'), expected_private)
self.assertEqual(cs.FnGetAtt('PublicDnsName'), expected_public)
self.assertEqual(cs.FnGetAtt('PrivateDnsName'), expected_public)
self.assertEqual(expected_public, cs.FnGetAtt('PublicIp'))
self.assertEqual(expected_private, cs.FnGetAtt('PrivateIp'))
self.assertEqual(expected_public, cs.FnGetAtt('PublicDnsName'))
self.assertEqual(expected_public, cs.FnGetAtt('PrivateDnsName'))
self.m.VerifyAll()
@ -200,10 +200,10 @@ class RackspaceCloudServerTest(HeatTestCase):
expected_public = return_server.networks['public'][0]
expected_private = return_server.networks['private'][0]
self.assertEqual(cs.FnGetAtt('PublicIp'), expected_public)
self.assertEqual(cs.FnGetAtt('PrivateIp'), expected_private)
self.assertEqual(cs.FnGetAtt('PublicDnsName'), expected_public)
self.assertEqual(cs.FnGetAtt('PrivateDnsName'), expected_public)
self.assertEqual(expected_public, cs.FnGetAtt('PublicIp'))
self.assertEqual(expected_private, cs.FnGetAtt('PrivateIp'))
self.assertEqual(expected_public, cs.FnGetAtt('PublicDnsName'))
self.assertEqual(expected_public, cs.FnGetAtt('PrivateDnsName'))
self.assertRaises(exception.InvalidTemplateAttribute,
cs.FnGetAtt, 'foo')
self.m.VerifyAll()
@ -317,7 +317,7 @@ class RackspaceCloudServerTest(HeatTestCase):
scheduler.TaskRunner(cs.delete)()
self.assertIsNone(cs.resource_id)
self.assertEqual(cs.state, (cs.DELETE, cs.COMPLETE))
self.assertEqual((cs.DELETE, cs.COMPLETE), cs.state)
self.m.VerifyAll()
def test_cs_update_metadata(self):
@ -329,7 +329,7 @@ class RackspaceCloudServerTest(HeatTestCase):
update_template = copy.deepcopy(cs.t)
update_template['Metadata'] = {'test': 123}
scheduler.TaskRunner(cs.update, update_template)()
self.assertEqual(cs.metadata, {'test': 123})
self.assertEqual({'test': 123}, cs.metadata)
def test_cs_update_replace(self):
return_server = self.fc.servers.list()[1]
@ -361,7 +361,7 @@ class RackspaceCloudServerTest(HeatTestCase):
self.m.ReplayAll()
scheduler.TaskRunner(cs.create)()
self.assertEqual(cs.state, (cs.CREATE, cs.COMPLETE))
self.assertEqual((cs.CREATE, cs.COMPLETE), cs.state)
def test_cs_status_hard_reboot(self):
self._test_cs_status_not_build_active('HARD_REBOOT')
@ -409,7 +409,7 @@ class RackspaceCloudServerTest(HeatTestCase):
self.m.ReplayAll()
scheduler.TaskRunner(cs.create)()
self.assertEqual(cs.state, (cs.CREATE, cs.COMPLETE))
self.assertEqual((cs.CREATE, cs.COMPLETE), cs.state)
self.m.VerifyAll()
@ -429,9 +429,9 @@ class RackspaceCloudServerTest(HeatTestCase):
{'version': 6, 'addr': 'fake:ip::6'}],
'private': [{'version': 4, 'addr': '10.13.12.13'}]}
self.mock_get_ip(cs)
self.assertEqual(cs.public_ip, '4.5.6.7')
self.assertEqual('4.5.6.7', cs.public_ip)
self.mock_get_ip(cs)
self.assertEqual(cs.private_ip, '10.13.12.13')
self.assertEqual('10.13.12.13', cs.private_ip)
cs.addresses = {'public': [],
'private': []}
@ -455,8 +455,8 @@ class RackspaceCloudServerTest(HeatTestCase):
stack.id)
encrypted_key = rs.data[0]['value']
self.assertNotEqual(encrypted_key, "fake private key")
decrypted_key = cs.private_key
self.assertEqual(decrypted_key, "fake private key")
# Test private_key property returns decrypted value
self.assertEqual("fake private key", cs.private_key)
def test_rackconnect_deployed(self):
return_server = self.fc.servers.list()[1]
@ -467,8 +467,8 @@ class RackspaceCloudServerTest(HeatTestCase):
cs.context.roles = ['rack_connect']
self.m.ReplayAll()
scheduler.TaskRunner(cs.create)()
self.assertEqual(cs.action, 'CREATE')
self.assertEqual(cs.status, 'COMPLETE')
self.assertEqual('CREATE', cs.action)
self.assertEqual('COMPLETE', cs.status)
self.m.VerifyAll()
def test_rackconnect_failed(self):
@ -496,8 +496,8 @@ class RackspaceCloudServerTest(HeatTestCase):
cs.context.roles = ['rack_connect']
self.m.ReplayAll()
scheduler.TaskRunner(cs.create)()
self.assertEqual(cs.action, 'CREATE')
self.assertEqual(cs.status, 'COMPLETE')
self.assertEqual('CREATE', cs.action)
self.assertEqual('COMPLETE', cs.status)
self.m.VerifyAll()
def test_rackconnect_unknown(self):
@ -522,8 +522,8 @@ class RackspaceCloudServerTest(HeatTestCase):
cs.context.roles = ['rax_managed']
self.m.ReplayAll()
scheduler.TaskRunner(cs.create)()
self.assertEqual(cs.action, 'CREATE')
self.assertEqual(cs.status, 'COMPLETE')
self.assertEqual('CREATE', cs.action)
self.assertEqual('COMPLETE', cs.status)
self.m.VerifyAll()
def test_managed_cloud_build_error(self):

@ -73,7 +73,7 @@ Outputs:
t = template_format.parse(template)
stack = self.parse_stack(t)
stack.create()
self.assertEqual(stack.state, (stack.CREATE, stack.COMPLETE))
self.assertEqual((stack.CREATE, stack.COMPLETE), stack.state)
return stack
def parse_stack(self, t):
@ -92,7 +92,7 @@ Outputs:
stack = self.create_stack(self.test_template)
rsrc = stack['the_nested']
nested_name = utils.PhysName(stack.name, 'the_nested')
self.assertEqual(nested_name, rsrc.physical_resource_name())
self.assertEqual(rsrc.physical_resource_name(), nested_name)
arn_prefix = ('arn:openstack:heat::aaaa:stacks/%s/' %
rsrc.physical_resource_name())
self.assertTrue(rsrc.FnGetRefId().startswith(arn_prefix))
@ -121,7 +121,7 @@ Outputs:
props['TimeoutInMinutes'] = '50'
stack = self.create_stack(json.dumps(timeout_template))
self.assertEqual(stack.state, (stack.CREATE, stack.COMPLETE))
self.assertEqual((stack.CREATE, stack.COMPLETE), stack.state)
self.m.VerifyAll()
def test_nested_stack_create_exceeds_resource_limit(self):
@ -146,7 +146,7 @@ Outputs:
t = template_format.parse(self.test_template)
stack = self.parse_stack(t)
stack.create()
self.assertEqual(stack.state, (stack.CREATE, stack.FAILED))
self.assertEqual((stack.CREATE, stack.FAILED), stack.state)
self.assertIn('Maximum resources per stack exceeded',
stack.status_reason)
@ -174,7 +174,7 @@ Outputs:
t = template_format.parse(self.test_template)
stack = self.parse_stack(t)
stack.create()
self.assertEqual(stack.state, (stack.CREATE, stack.COMPLETE))
self.assertEqual((stack.CREATE, stack.COMPLETE), stack.state)
self.assertIn('NestedResource',
stack['the_nested'].nested())
@ -310,10 +310,10 @@ Outputs:
rsrc = stack['the_nested']
scheduler.TaskRunner(rsrc.suspend)()
self.assertEqual(rsrc.state, (rsrc.SUSPEND, rsrc.COMPLETE))
self.assertEqual((rsrc.SUSPEND, rsrc.COMPLETE), rsrc.state)
scheduler.TaskRunner(rsrc.resume)()
self.assertEqual(rsrc.state, (rsrc.RESUME, rsrc.COMPLETE))
self.assertEqual((rsrc.RESUME, rsrc.COMPLETE), rsrc.state)
rsrc.delete()
self.m.VerifyAll()
@ -474,7 +474,7 @@ Resources:
t = template_format.parse(template)
stack = self.parse_stack(t)
stack.create()
self.assertEqual(stack.state, (stack.CREATE, stack.FAILED))
self.assertEqual((stack.CREATE, stack.FAILED), stack.state)
self.assertIn('Recursion depth exceeds', stack.status_reason)
self.m.VerifyAll()
@ -545,6 +545,6 @@ Outputs:
stack = self.create_stack(self.test_template)
res = stack['the_nested'].nested()['nested_res']
stack.delete()
self.assertEqual(stack.state, (stack.DELETE, stack.COMPLETE))
self.assertEqual((stack.DELETE, stack.COMPLETE), stack.state)
self.assertRaises(exception.NotFound, db_api.resource_data_get, res,
'test')

@ -357,8 +357,8 @@ class AutoScalingTest(HeatTestCase):
stack.store()
stack.create()
self.assertEqual(stack.state,
(parser.Stack.CREATE, parser.Stack.COMPLETE))
self.assertEqual((parser.Stack.CREATE, parser.Stack.COMPLETE),
stack.state)
# Start of stack update
stack2 = parser.Stack.load(self.ctx, stack_id=stack.id)
@ -370,8 +370,8 @@ class AutoScalingTest(HeatTestCase):
template.Template(tmpl2),
environment.Environment(env))
stack2.update(update_stack)
self.assertEqual(stack2.state,
(parser.Stack.UPDATE, parser.Stack.COMPLETE))
self.assertEqual((parser.Stack.UPDATE, parser.Stack.COMPLETE),
stack2.state)
members = db_api.resource_data_get_all(stack['ElasticLoadBalancer'])
self.assertEqual(3, len(members.keys()))

@ -102,8 +102,8 @@ class NotificationTest(common.HeatTestCase):
with mock.patch('heat.openstack.common.notifier.api.notify') \
as mock_notify:
self.create_test_stack()
self.assertEqual(self.stack.state, (self.stack.CREATE,
self.stack.COMPLETE))
self.assertEqual((self.stack.CREATE, self.stack.COMPLETE),
self.stack.state)
self.assertEqual(self.expected['create'],
mock_notify.call_args_list)
@ -113,33 +113,32 @@ class NotificationTest(common.HeatTestCase):
with mock.patch('heat.openstack.common.notifier.api.notify') \
as mock_notify:
self.create_test_stack()
self.assertEqual(self.stack.state, (self.stack.CREATE,
self.stack.COMPLETE))
self.assertEqual((self.stack.CREATE, self.stack.COMPLETE),
self.stack.state)
self.assertEqual(self.expected['create'],
mock_notify.call_args_list)
self.stack.suspend()
self.assertEqual(self.stack.state, (self.stack.SUSPEND,
self.stack.COMPLETE))
expected = self.expected['create'] + self.expected['suspend']
self.assertEqual((self.stack.SUSPEND, self.stack.COMPLETE),
self.stack.state)
self.assertEqual(expected,
mock_notify.call_args_list)
expected = self.expected['create'] + self.expected['suspend']
self.assertEqual(expected, mock_notify.call_args_list)
@utils.stack_delete_after
def test_create_and_delete_stack(self):
with mock.patch('heat.openstack.common.notifier.api.notify') \
as mock_notify:
self.create_test_stack()
self.assertEqual(self.stack.state, (self.stack.CREATE,
self.stack.COMPLETE))
self.assertEqual((self.stack.CREATE, self.stack.COMPLETE),
self.stack.state)
self.assertEqual(self.expected['create'],
mock_notify.call_args_list)
self.stack.delete()
self.assertEqual(self.stack.state, (self.stack.DELETE,
self.stack.COMPLETE))
self.assertEqual((self.stack.DELETE, self.stack.COMPLETE),
self.stack.state)
expected = self.expected['create'] + self.expected['delete']
self.assertEqual(expected,
mock_notify.call_args_list)
expected = self.expected['create'] + self.expected['delete']
self.assertEqual(expected, mock_notify.call_args_list)

@ -89,7 +89,7 @@ class NovaKeyPairTest(HeatTestCase):
self.assertEqual("generated test public key",
tp_test.FnGetAtt('public_key'))
self.assertEqual((tp_test.CREATE, tp_test.COMPLETE), tp_test.state)
self.assertEqual(created_key.name, tp_test.resource_id)
self.assertEqual(tp_test.resource_id, created_key.name)
self.m.VerifyAll()
def test_delete_key(self):
@ -127,7 +127,7 @@ class NovaKeyPairTest(HeatTestCase):
self.assertEqual("test_create_pub",
tp_test.FnGetAtt('public_key'))
self.assertEqual((tp_test.CREATE, tp_test.COMPLETE), tp_test.state)
self.assertEqual(created_key.name, tp_test.resource_id)
self.assertEqual(tp_test.resource_id, created_key.name)
self.m.VerifyAll()
def test_save_priv_key(self):
@ -143,5 +143,5 @@ class NovaKeyPairTest(HeatTestCase):
self.assertEqual("generated test public key",
tp_test.FnGetAtt('public_key'))
self.assertEqual((tp_test.CREATE, tp_test.COMPLETE), tp_test.state)
self.assertEqual(created_key.name, tp_test.resource_id)
self.assertEqual(tp_test.resource_id, created_key.name)
self.m.VerifyAll()

@ -60,8 +60,8 @@ class ParameterTest(testtools.TestCase):
p = self.new_parameter('defaulted', {'Type': 'String',
'Default': 'blarg'})
self.assertTrue(p.has_default())
self.assertEqual(p.default(), 'blarg')
self.assertEqual(p.value(), 'blarg')
self.assertEqual('blarg', p.default())
self.assertEqual('blarg', p.value())
def test_default_override(self):
p = self.new_parameter('defaulted',
@ -69,8 +69,8 @@ class ParameterTest(testtools.TestCase):
'Default': 'blarg'},
'wibble')
self.assertTrue(p.has_default())
self.assertEqual(p.default(), 'blarg')
self.assertEqual(p.value(), 'wibble')
self.assertEqual('blarg', p.default())
self.assertEqual('wibble', p.value())
def test_default_invalid(self):
schema = {'Type': 'String',
@ -103,25 +103,25 @@ class ParameterTest(testtools.TestCase):
'NoEcho': 'false'},
'wibble')
self.assertFalse(p.no_echo())
self.assertEqual(str(p), 'wibble')
self.assertEqual('wibble', str(p))
def test_description(self):
description = 'Description of the parameter'
p = self.new_parameter('p', {'Type': 'String',
'Description': description},
validate_value=False)
self.assertEqual(p.description(), description)
self.assertEqual(description, p.description())
def test_no_description(self):
p = self.new_parameter('p', {'Type': 'String'}, validate_value=False)
self.assertEqual(p.description(), '')
self.assertEqual('', p.description())
def test_string_len_good(self):
schema = {'Type': 'String',
'MinLength': '3',
'MaxLength': '3'}
p = self.new_parameter('p', schema, 'foo')
self.assertEqual(p.value(), 'foo')
self.assertEqual('foo', p.value())
def test_string_underflow(self):
schema = {'Type': 'String',
@ -143,7 +143,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'String',
'AllowedPattern': '[a-z]*'}
p = self.new_parameter('p', schema, 'foo')
self.assertEqual(p.value(), 'foo')
self.assertEqual('foo', p.value())
def test_string_pattern_bad_prefix(self):
schema = {'Type': 'String',
@ -165,7 +165,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'String',
'AllowedValues': ['foo', 'bar', 'baz']}
p = self.new_parameter('p', schema, 'bar')
self.assertEqual(p.value(), 'bar')
self.assertEqual('bar', p.value())
def test_string_value_list_bad(self):
schema = {'Type': 'String',
@ -180,14 +180,14 @@ class ParameterTest(testtools.TestCase):
'MinValue': '3',
'MaxValue': '3'}
p = self.new_parameter('p', schema, '3')
self.assertEqual(p.value(), 3)
self.assertEqual(3, p.value())
def test_number_float_good(self):
schema = {'Type': 'Number',
'MinValue': '3.0',
'MaxValue': '4.0'}
p = self.new_parameter('p', schema, '3.5')
self.assertEqual(p.value(), 3.5)
self.assertEqual(3.5, p.value())
def test_number_low(self):
schema = {'Type': 'Number',
@ -209,7 +209,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'Number',
'AllowedValues': ['1', '3', '5']}
p = self.new_parameter('p', schema, '5')
self.assertEqual(p.value(), 5)
self.assertEqual(5, p.value())
def test_number_value_list_bad(self):
schema = {'Type': 'Number',
@ -223,13 +223,13 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'CommaDelimitedList',
'AllowedValues': ['foo', 'bar', 'baz']}
p = self.new_parameter('p', schema, 'baz,foo,bar')
self.assertEqual(p.value(), 'baz,foo,bar'.split(','))
self.assertEqual('baz,foo,bar'.split(','), p.value())
schema['Default'] = []
p = self.new_parameter('p', schema)
self.assertEqual(p.value(), [])
self.assertEqual([], p.value())
schema['Default'] = 'baz,foo,bar'
p = self.new_parameter('p', schema)
self.assertEqual(p.value(), 'baz,foo,bar'.split(','))
self.assertEqual('baz,foo,bar'.split(','), p.value())
def test_list_value_list_bad(self):
schema = {'Type': 'CommaDelimitedList',
@ -339,26 +339,26 @@ class ParametersTest(testtools.TestCase):
def test_pseudo_params(self):
params = self.new_parameters('test_stack', {"Parameters": {}})
self.assertEqual(params['AWS::StackName'], 'test_stack')
self.assertEqual(params['AWS::StackId'], 'None')
self.assertEqual('test_stack', params['AWS::StackName'])
self.assertEqual('None', params['AWS::StackId'])
self.assertIn('AWS::Region', params)
def test_pseudo_param_stackid(self):
params = self.new_parameters('test_stack', {'Parameters': {}},
stack_id='123::foo')
self.assertEqual(params['AWS::StackId'], '123::foo')
self.assertEqual('123::foo', params['AWS::StackId'])
params.set_stack_id('456::bar')
self.assertEqual(params['AWS::StackId'], '456::bar')
self.assertEqual('456::bar', params['AWS::StackId'])
def test_schema_invariance(self):
params1 = self.new_parameters('test', params_schema,
{'User': 'foo',
'Defaulted': 'wibble'})
self.assertEqual(params1['Defaulted'], 'wibble')
self.assertEqual('wibble', params1['Defaulted'])
params2 = self.new_parameters('test', params_schema, {'User': 'foo'})
self.assertEqual(params2['Defaulted'], 'foobar')
self.assertEqual('foobar', params2['Defaulted'])
def test_to_dict(self):
template = {'Parameters': {'Foo': {'Type': 'String'},
@ -366,9 +366,9 @@ class ParametersTest(testtools.TestCase):
params = self.new_parameters('test_params', template, {'Foo': 'foo'})
as_dict = dict(params)
self.assertEqual(as_dict['Foo'], 'foo')
self.assertEqual(as_dict['Bar'], 42)
self.assertEqual(as_dict['AWS::StackName'], 'test_params')
self.assertEqual('foo', as_dict['Foo'])
self.assertEqual(42, as_dict['Bar'])
self.assertEqual('test_params', as_dict['AWS::StackName'])
self.assertIn('AWS::Region', as_dict)
def test_map(self):
@ -382,7 +382,7 @@ class ParametersTest(testtools.TestCase):
'AWS::StackId': True,
'AWS::StackName': True}
self.assertEqual(params.map(lambda p: p.has_default()), expected)
self.assertEqual(expected, params.map(lambda p: p.has_default()))
def test_map_str(self):
template = {'Parameters': {'Foo': {'Type': 'String'},
@ -396,7 +396,7 @@ class ParametersTest(testtools.TestCase):
'AWS::StackId': 'None',
'AWS::StackName': 'test_params'}
self.assertEqual(params.map(str), expected)
self.assertEqual(expected, params.map(str))
def test_unknown_params(self):
user_params = {'Foo': 'wibble'}

File diff suppressed because it is too large Load Diff

@ -23,8 +23,8 @@ from heat.common import plugin_loader
class PluginLoaderTest(testtools.TestCase):
def test_module_name(self):
self.assertEqual(plugin_loader._module_name('foo.bar', 'blarg.wibble'),
'foo.bar.blarg.wibble')
self.assertEqual('foo.bar.blarg.wibble',
plugin_loader._module_name('foo.bar', 'blarg.wibble'))
def test_create_subpackage_single_path(self):
pkg_name = 'heat.engine.test_single_path'
@ -34,8 +34,8 @@ class PluginLoaderTest(testtools.TestCase):
'test_single_path')
self.assertIn(pkg_name, sys.modules)
self.assertEqual(sys.modules[pkg_name], pkg)
self.assertEqual(pkg.__path__, ['/tmp'])
self.assertEqual(pkg.__name__, pkg_name)
self.assertEqual(['/tmp'], pkg.__path__)
self.assertEqual(pkg_name, pkg.__name__)
def test_create_subpackage_path_list(self):
path_list = ['/tmp']
@ -46,9 +46,9 @@ class PluginLoaderTest(testtools.TestCase):
'test_path_list')
self.assertIn(pkg_name, sys.modules)
self.assertEqual(sys.modules[pkg_name], pkg)
self.assertEqual(pkg.__path__, path_list)
self.assertEqual(path_list, pkg.__path__)
self.assertNotIn(pkg.__path__, path_list)
self.assertEqual(pkg.__name__, pkg_name)
self.assertEqual(pkg_name, pkg.__name__)
def test_import_module_existing(self):
import heat.engine.service

@ -597,11 +597,11 @@ class PropertyTest(testtools.TestCase):
def test_default(self):
p = properties.Property({'Type': 'String', 'Default': 'wibble'})
self.assertEqual(p.default(), 'wibble')
self.assertEqual('wibble', p.default())
def test_type(self):
p = properties.Property({'Type': 'String'})
self.assertEqual(p.type(), 'String')
self.assertEqual('String', p.type())
def test_bad_type(self):
self.assertRaises(constraints.InvalidSchemaError,
@ -616,7 +616,7 @@ class PropertyTest(testtools.TestCase):
schema = {'Type': 'String',
'AllowedPattern': '[a-z]*'}
p = properties.Property(schema)
self.assertEqual(p.validate_data('foo'), 'foo')
self.assertEqual('foo', p.validate_data('foo'))
def test_string_pattern_bad_prefix(self):
schema = {'Type': 'String',
@ -634,7 +634,7 @@ class PropertyTest(testtools.TestCase):
schema = {'Type': 'String',
'AllowedValues': ['foo', 'bar', 'baz']}
p = properties.Property(schema)
self.assertEqual(p.validate_data('bar'), 'bar')
self.assertEqual('bar', p.validate_data('bar'))
def test_string_value_list_bad(self):
schema = {'Type': 'String',
@ -646,7 +646,7 @@ class PropertyTest(testtools.TestCase):
schema = {'Type': 'String',
'MaxLength': '5'}
p = properties.Property(schema)
self.assertEqual(p.validate_data('abcd'), 'abcd')
self.assertEqual('abcd', p.validate_data('abcd'))
def test_string_exceeded_maxlength(self):
schema = {'Type': 'String',
@ -659,13 +659,13 @@ class PropertyTest(testtools.TestCase):
'MinLength': '5',
'MaxLength': '10'}
p = properties.Property(schema)
self.assertEqual(p.validate_data('abcdef'), 'abcdef')
self.assertEqual('abcdef', p.validate_data('abcdef'))
def test_string_minlength_good(self):
schema = {'Type': 'String',
'MinLength': '5'}
p = properties.Property(schema)
self.assertEqual(p.validate_data('abcde'), 'abcde')
self.assertEqual('abcde', p.validate_data('abcde'))
def test_string_smaller_than_minlength(self):
schema = {'Type': 'String',
@ -678,7 +678,7 @@ class PropertyTest(testtools.TestCase):
'MinValue': 3,
'MaxValue': 3}
p = properties.Property(schema)
self.assertEqual(p.validate_data(3), 3)
self.assertEqual(3, p.validate_data(3))
def test_int_bad(self):
schema = {'Type': 'Integer'}
@ -714,7 +714,7 @@ class PropertyTest(testtools.TestCase):
schema = {'Type': 'Integer',
'AllowedValues': [1, 3, 5]}
p = properties.Property(schema)
self.assertEqual(p.validate_data(5), 5)
self.assertEqual(5, p.validate_data(5))
def test_integer_value_list_bad(self):
schema = {'Type': 'Integer',
@ -727,7 +727,7 @@ class PropertyTest(testtools.TestCase):
'MinValue': '3',
'MaxValue': '3'}
p = properties.Property(schema)
self.assertEqual(p.validate_data(3), 3)
self.assertEqual(3, p.validate_data(3))
def test_numbers_from_strings(self):
"""Numbers can be converted from strings."""
@ -735,13 +735,13 @@ class PropertyTest(testtools.TestCase):
'MinValue': '3',
'MaxValue': '3'}
p = properties.Property(schema)
self.assertEqual(p.validate_data('3'), 3)
self.assertEqual(3, p.validate_data('3'))
def test_number_value_list_good(self):
schema = {'Type': 'Number',
'AllowedValues': [1, 3, 5]}
p = properties.Property(schema)
self.assertEqual(p.validate_data('5'), 5)
self.assertEqual(5, p.validate_data('5'))
def test_number_value_list_bad(self):
schema = {'Type': 'Number',
@ -783,7 +783,7 @@ class PropertyTest(testtools.TestCase):
def test_list_good(self):
p = properties.Property({'Type': 'List'})
self.assertEqual(p.validate_data(['foo', 'bar']), ['foo', 'bar'])
self.assertEqual(['foo', 'bar'], p.validate_data(['foo', 'bar']))
def test_list_dict(self):
p = properties.Property({'Type': 'List'})
@ -793,7 +793,7 @@ class PropertyTest(testtools.TestCase):
schema = {'Type': 'List',
'MaxLength': '3'}
p = properties.Property(schema)
self.assertEqual(p.validate_data(['1', '2']), ['1', '2'])
self.assertEqual(['1', '2'], p.validate_data(['1', '2']))
def test_list_exceeded_maxlength(self):
schema = {'Type': 'List',
@ -806,13 +806,13 @@ class PropertyTest(testtools.TestCase):
'MinLength': '2',
'MaxLength': '4'}
p = properties.Property(schema)
self.assertEqual(p.validate_data(['1', '2', '3']), ['1', '2', '3'])
self.assertEqual(['1', '2', '3'], p.validate_data(['1', '2', '3']))
def test_list_minlength_good(self):
schema = {'Type': 'List',
'MinLength': '3'}
p = properties.Property(schema)
self.assertEqual(p.validate_data(['1', '2', '3']), ['1', '2', '3'])
self.assertEqual(['1', '2', '3'], p.validate_data(['1', '2', '3']))
def test_list_smaller_than_minlength(self):
schema = {'Type': 'List',
@ -831,7 +831,7 @@ class PropertyTest(testtools.TestCase):
def test_map_schema_good(self):
map_schema = {'valid': {'Type': 'Boolean'}}
p = properties.Property({'Type': 'Map', 'Schema': map_schema})
self.assertEqual(p.validate_data({'valid': 'TRUE'}), {'valid': True})
self.assertEqual({'valid': True}, p.validate_data({'valid': 'TRUE'}))
def test_map_schema_bad_data(self):
map_schema = {'valid': {'Type': 'Boolean'}}
@ -841,7 +841,7 @@ class PropertyTest(testtools.TestCase):
def test_map_schema_missing_data(self):
map_schema = {'valid': {'Type': 'Boolean'}}
p = properties.Property({'Type': 'Map', 'Schema': map_schema})
self.assertEqual(p.validate_data({}), {'valid': None})
self.assertEqual({'valid': None}, p.validate_data({}))
def test_map_schema_missing_required_data(self):
map_schema = {'valid': {'Type': 'Boolean', 'Required': True}}
@ -852,9 +852,10 @@ class PropertyTest(testtools.TestCase):
map_schema = {'valid': {'Type': 'Boolean'}}
list_schema = {'Type': 'Map', 'Schema': map_schema}
p = properties.Property({'Type': 'List', 'Schema': list_schema})
self.assertEqual(p.validate_data(
[{'valid': 'TRUE'}, {'valid': 'False'}]),
[{'valid': True}, {'valid': False}])
self.assertEqual([{'valid': True},
{'valid': False}],
p.validate_data([{'valid': 'TRUE'},
{'valid': 'False'}]))
def test_list_schema_bad_data(self):
map_schema = {'valid': {'Type': 'Boolean'}}
@ -866,7 +867,7 @@ class PropertyTest(testtools.TestCase):