From c0a3bcbfa34961984083e15b1614026ddab15e63 Mon Sep 17 00:00:00 2001 From: rabi Date: Wed, 29 Mar 2017 09:29:56 +0530 Subject: [PATCH] Fix format_stack_preview for py3 Also fixes test_res_group_with_nested_template functional test. Change-Id: I23fab6b8acc11bb32332dd0042ecd6b8ac289f56 --- heat/engine/api.py | 2 +- heat_integrationtests/functional/test_preview.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/heat/engine/api.py b/heat/engine/api.py index f80b05ef4..049043f60 100644 --- a/heat/engine/api.py +++ b/heat/engine/api.py @@ -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) diff --git a/heat_integrationtests/functional/test_preview.py b/heat_integrationtests/functional/test_preview.py index 99c24ebd3..4b9d77c6b 100644 --- a/heat_integrationtests/functional/test_preview.py +++ b/heat_integrationtests/functional/test_preview.py @@ -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)