Fix format_stack_preview for py3

Also fixes test_res_group_with_nested_template functional
test.

Change-Id: I23fab6b8acc11bb32332dd0042ecd6b8ac289f56
This commit is contained in:
rabi 2017-03-29 09:29:56 +05:30
parent e066ca2461
commit c0a3bcbfa3
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)