py34: heat.tests.api.cfn

The recursive sort utility function in the repository
won't work for python 3 because it can't sort dictionaries
inside lists. Python 2 could but python 3 forbids that.
It does not seem possible to have a simple one size fits all
sorted function to recursively sort lists of dictionaries,
hence just workaround by manually sorting by key or value.

partial blueprint heat-python34-support

Change-Id: I3b8073208baa9927aa8054cea600f627608caa4f
This commit is contained in:
Sirushti Murugesan 2015-09-22 21:12:10 +05:30
parent f1a0ccc04f
commit 0e2f02c129
2 changed files with 33 additions and 24 deletions

View File

@ -312,18 +312,18 @@ class CfnStackControllerTest(common.HeatTestCase):
'StackStatusReason': u'Stack successfully created',
'Description': u'blah',
'Parameters':
[{'ParameterValue': u'admin',
'ParameterKey': u'DBUsername'},
{'ParameterValue': u'F17',
'ParameterKey': u'LinuxDistribution'},
{'ParameterValue': u'm1.large',
'ParameterKey': u'InstanceType'},
[{'ParameterValue': u'wordpress',
'ParameterKey': u'DBName'},
{'ParameterValue': u'admin',
'ParameterKey': u'DBPassword'},
{'ParameterValue': u'admin',
'ParameterKey': u'DBRootPassword'},
{'ParameterValue': u'admin',
'ParameterKey': u'DBPassword'},
{'ParameterValue': u'wordpress',
'ParameterKey': u'DBName'}],
'ParameterKey': u'DBUsername'},
{'ParameterValue': u'm1.large',
'ParameterKey': u'InstanceType'},
{'ParameterValue': u'F17',
'ParameterKey': u'LinuxDistribution'}],
'Outputs':
[{'OutputKey': u'WebsiteURL',
'OutputValue': u'http://10.0.0.8/wordpress',
@ -336,9 +336,13 @@ class CfnStackControllerTest(common.HeatTestCase):
'StackStatus': u'CREATE_COMPLETE',
'DisableRollback': 'true',
'LastUpdatedTime': u'2012-07-09T09:13:11Z'}]}}}
self.assertEqual(utils.recursive_sort(expected),
utils.recursive_sort(response))
stacks = (response['DescribeStacksResponse']['DescribeStacksResult']
['Stacks'])
stacks[0]['Parameters'] = sorted(
stacks[0]['Parameters'], key=lambda k: k['ParameterKey'])
response['DescribeStacksResponse']['DescribeStacksResult'] = (
{'Stacks': stacks})
self.assertEqual(expected, response)
def test_describe_arn(self):
# Format a dummy GET request to pass into the WSGI handler
@ -397,18 +401,18 @@ class CfnStackControllerTest(common.HeatTestCase):
'StackStatusReason': u'Stack successfully created',
'Description': u'blah',
'Parameters':
[{'ParameterValue': u'admin',
'ParameterKey': u'DBUsername'},
{'ParameterValue': u'F17',
'ParameterKey': u'LinuxDistribution'},
{'ParameterValue': u'm1.large',
'ParameterKey': u'InstanceType'},
[{'ParameterValue': u'wordpress',
'ParameterKey': u'DBName'},
{'ParameterValue': u'admin',
'ParameterKey': u'DBPassword'},
{'ParameterValue': u'admin',
'ParameterKey': u'DBRootPassword'},
{'ParameterValue': u'admin',
'ParameterKey': u'DBPassword'},
{'ParameterValue': u'wordpress',
'ParameterKey': u'DBName'}],
'ParameterKey': u'DBUsername'},
{'ParameterValue': u'm1.large',
'ParameterKey': u'InstanceType'},
{'ParameterValue': u'F17',
'ParameterKey': u'LinuxDistribution'}],
'Outputs':
[{'OutputKey': u'WebsiteURL',
'OutputValue': u'http://10.0.0.8/wordpress',
@ -421,9 +425,13 @@ class CfnStackControllerTest(common.HeatTestCase):
'StackStatus': u'CREATE_COMPLETE',
'DisableRollback': 'true',
'LastUpdatedTime': u'2012-07-09T09:13:11Z'}]}}}
self.assertEqual(utils.recursive_sort(expected),
utils.recursive_sort(response))
stacks = (response['DescribeStacksResponse']['DescribeStacksResult']
['Stacks'])
stacks[0]['Parameters'] = sorted(
stacks[0]['Parameters'], key=lambda k: k['ParameterKey'])
response['DescribeStacksResponse']['DescribeStacksResult'] = (
{'Stacks': stacks})
self.assertEqual(expected, response)
def test_describe_arn_invalidtenant(self):
# Format a dummy GET request to pass into the WSGI handler

View File

@ -2,6 +2,7 @@ rackspace.tests
heat_docker.tests
heat.tests.api.aws.test_api_aws
heat.tests.api.aws.test_api_ec2token
heat.tests.api.cfn.test_api_v1
heat.tests.api.middleware.test_ssl_middleware
heat.tests.api.middleware.test_version_negotiation_middleware
heat.tests.api.openstack_v1.test_stacks_view