From 5538b541a89cf7efd269cc938602ff3f3a133816 Mon Sep 17 00:00:00 2001 From: Taro Sato Date: Mon, 31 Oct 2016 11:29:39 -0700 Subject: [PATCH] Fix a bug with map type not properly handling multiple entries --- moto/core/responses.py | 11 ++++++++--- tests/test_emr/test_emr.py | 2 ++ tests/test_emr/test_emr_boto3.py | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/moto/core/responses.py b/moto/core/responses.py index 437937207..87299157e 100644 --- a/moto/core/responses.py +++ b/moto/core/responses.py @@ -576,9 +576,14 @@ def xml_to_json_response(service_spec, operation, xml, result_node=None): if v is None: od[k] = {} else: - key = from_str(v['entry']['key'], spec[k]['key']) - val = from_str(v['entry']['value'], spec[k]['value']) - od[k] = {key: val} + items = ([v['entry']] if not isinstance(v['entry'], list) else + v['entry']) + for item in items: + key = from_str(item['key'], spec[k]['key']) + val = from_str(item['value'], spec[k]['value']) + if k not in od: + od[k] = {} + od[k][key] = val else: if v is None: od[k] = None diff --git a/tests/test_emr/test_emr.py b/tests/test_emr/test_emr.py index 9fe67513e..259d2a07d 100644 --- a/tests/test_emr/test_emr.py +++ b/tests/test_emr/test_emr.py @@ -43,6 +43,8 @@ def test_describe_cluster(): 'Configurations.member.1.Classification': 'yarn-site', 'Configurations.member.1.Properties.entry.1.key': 'someproperty', 'Configurations.member.1.Properties.entry.1.value': 'somevalue', + 'Configurations.member.1.Properties.entry.2.key': 'someotherproperty', + 'Configurations.member.1.Properties.entry.2.value': 'someothervalue', 'Instances.EmrManagedMasterSecurityGroup': 'master-security-group', 'Instances.Ec2SubnetId': 'subnet-8be41cec', }, diff --git a/tests/test_emr/test_emr_boto3.py b/tests/test_emr/test_emr_boto3.py index 4e297e620..dcff57bce 100644 --- a/tests/test_emr/test_emr_boto3.py +++ b/tests/test_emr/test_emr_boto3.py @@ -60,7 +60,8 @@ def test_describe_cluster(): args['Applications'] = [{'Name': 'Spark', 'Version': '2.4.2'}] args['Configurations'] = [ {'Classification': 'yarn-site', - 'Properties': {'someproperty': 'somevalue'}}] + 'Properties': {'someproperty': 'somevalue', + 'someotherproperty': 'someothervalue'}}] args['Instances']['AdditionalMasterSecurityGroups'] = ['additional-master'] args['Instances']['AdditionalSlaveSecurityGroups'] = ['additional-slave'] args['Instances']['Ec2KeyName'] = 'mykey'