Skip to content

Commit

Permalink
Fix serialization of ChangeTagsForResource
Browse files Browse the repository at this point in the history
This was serialization an xmlnode of 'None', because
there was no xmlname in the parameter.  This adds a fallback
to the ``name`` attribute if ``xmlname`` is not available.
  • Loading branch information
jamesls committed Jul 30, 2014
1 parent 5246071 commit 2b16585
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion botocore/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def to_xml(self, value, label=None):
return inner_xml
else:
if not label:
label = self.xmlname
label = self.xmlname or self.name
return '<%s>' % label + inner_xml + '</%s>' % label


Expand Down
18 changes: 14 additions & 4 deletions tests/unit/test_route53_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
CREATE_RRSET_PAYLOAD="""<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/"><ChangeBatch><Comment>Adding TXT record</Comment><Changes><Change><Action>CREATE</Action><ResourceRecordSet><Name>midocs.com</Name><Type>TXT</Type><TTL>600</TTL><ResourceRecords><ResourceRecord><Value>"v=foobar"</Value></ResourceRecord></ResourceRecords></ResourceRecordSet></Change></Changes></ChangeBatch></ChangeResourceRecordSetsRequest>"""
DELETE_RRSET_PAYLOAD="""<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/"><ChangeBatch><Comment>Adding TXT record</Comment><Changes><Change><Action>DELETE</Action><ResourceRecordSet><Name>midocs.com</Name><Type>TXT</Type><TTL>600</TTL><ResourceRecords><ResourceRecord><Value>"v=foobar"</Value></ResourceRecord></ResourceRecords></ResourceRecordSet></Change></Changes></ChangeBatch></ChangeResourceRecordSetsRequest>"""
CREATE_HEALTH_CHECK_PAYLOAD="""<CreateHealthCheckRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/"><CallerReference>foobar</CallerReference><HealthCheckConfig><IPAddress>192.168.10.0</IPAddress><Port>8888</Port><Type>HTTP</Type><ResourcePath>foo/bar</ResourcePath><FullyQualifiedDomainName>foobar.com</FullyQualifiedDomainName></HealthCheckConfig></CreateHealthCheckRequest>"""
CHANGE_TAGS_FOR_RESOURCE_PAYLOAD = """<ChangeTagsForResourceRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/"><AddTags><Tag><Key>keyname</Key><Value>valuename</Value></Tag></AddTags></ChangeTagsForResourceRequest>"""


class TestRoute53Operations(BaseSessionTest):

maxDiff = None

def setUp(self):
super(TestRoute53Operations, self).setUp()
self.environ['AWS_ACCESS_KEY_ID'] = 'foo'
Expand All @@ -38,7 +41,6 @@ def test_create_hosted_zone(self):
params = op.build_parameters(name=self.hosted_zone_name,
caller_reference='foobar',
hosted_zone_config=hzc)
self.maxDiff = None
self.assertEqual(params['payload'].getvalue(),
CREATE_HOSTED_ZONE_PAYLOAD)

Expand All @@ -54,7 +56,6 @@ def test_create_resource_record_sets(self):
{"Value":"\"v=foobar\""}]}}]}
params = op.build_parameters(hosted_zone_id='1111',
change_batch=batch)
self.maxDiff = None
self.assertEqual(params['payload'].getvalue(),
CREATE_RRSET_PAYLOAD)

Expand All @@ -70,7 +71,6 @@ def test_delete_resource_record_sets(self):
{"Value":"\"v=foobar\""}]}}]}
params = op.build_parameters(hosted_zone_id='1111',
change_batch=batch)
self.maxDiff = None
self.assertEqual(params['payload'].getvalue(),
DELETE_RRSET_PAYLOAD)

Expand All @@ -83,6 +83,16 @@ def test_create_healthcheck(self):
'FullyQualifiedDomainName': 'foobar.com'}
params = op.build_parameters(caller_reference='foobar',
health_check_config=hc_config)
self.maxDiff = None
self.assertEqual(params['payload'].getvalue(),
CREATE_HEALTH_CHECK_PAYLOAD)

def test_change_tags_for_resource(self):
op = self.route53.get_operation('ChangeTagsForResource')
arguments = {
'ResourceType': 'healthcheck',
'ResourceId': 'foo',
'AddTags': [{'Key': 'keyname', 'Value': 'valuename'}]
}
params = op.build_parameters(**arguments)
self.assertEqual(params['payload'].getvalue(),
CHANGE_TAGS_FOR_RESOURCE_PAYLOAD)

0 comments on commit 2b16585

Please sign in to comment.