Merge "Fix format_stack_preview for py3"

This commit is contained in:
Jenkins 2017-04-05 16:19:00 +00:00 committed by Gerrit Code Review
commit b5359cedf1
2 changed files with 13 additions and 5 deletions

View File

@ -367,7 +367,7 @@ def format_stack_resource(resource, detail=True, with_props=False,
def format_stack_preview(stack):
def format_resource(res):
if isinstance(res, list):
return map(format_resource, res)
return list(map(format_resource, res))
return format_stack_resource(res, with_props=True)
fmt_stack = format_stack(stack, preview=True)

View File

@ -222,8 +222,16 @@ resources:
stack_name=stack_name,
template=main_template,
files={'nested.yaml': nested_template}).to_dict()
resource_names = []
def get_resource_names(resources):
for item in resources:
if isinstance(item, dict):
resource_names.append(item['resource_name'])
else:
get_resource_names(item)
get_resource_names(result['resources'])
# ensure that fixed network and port here
self.assertEqual('fixed_network',
result['resources'][0]['resource_name'])
self.assertEqual('port',
result['resources'][1][0][0]['resource_name'])
self.assertIn('fixed_network', resource_names)
self.assertIn('port', resource_names)