Merge pull request #710 from kryptek/master

Fix Route53 tagging code
This commit is contained in:
Steve Pulec 2016-10-09 18:58:17 -04:00 committed by GitHub
commit 81d489ce46
2 changed files with 12 additions and 9 deletions

View File

@ -238,18 +238,19 @@ class Route53Backend(BaseBackend):
def change_tags_for_resource(self, resource_id, tags): def change_tags_for_resource(self, resource_id, tags):
if 'Tag' in tags: if 'Tag' in tags:
for key, tag in tags.items(): if isinstance(tags['Tag'], list):
for t in tag: for tag in tags['Tag']:
self.resource_tags[resource_id][t['Key']] = t['Value'] self.resource_tags[resource_id][tag['Key']] = tag['Value']
else: else:
for _, keys in tags.items(): key, value = (tags['Tag']['Key'], tags['Tag']['Value'])
if isinstance(keys, list): self.resource_tags[resource_id][key] = value
for key in keys: else:
if 'Key' in tags:
if isinstance(tags['Key'], list):
for key in tags['Key']:
del(self.resource_tags[resource_id][key]) del(self.resource_tags[resource_id][key])
else: else:
del(self.resource_tags[resource_id][keys]) del(self.resource_tags[resource_id][tags['Key']])
def list_tags_for_resource(self, resource_id): def list_tags_for_resource(self, resource_id):
if resource_id in self.resource_tags: if resource_id in self.resource_tags:

View File

@ -354,6 +354,8 @@ def test_list_or_change_tags_for_resource_request():
response['ResourceTagSet']['Tags'].should.contain(tag1) response['ResourceTagSet']['Tags'].should.contain(tag1)
response['ResourceTagSet']['Tags'].should.contain(tag2) response['ResourceTagSet']['Tags'].should.contain(tag2)
len(response['ResourceTagSet']['Tags']).should.equal(2)
# Try to remove the tags # Try to remove the tags
conn.change_tags_for_resource( conn.change_tags_for_resource(
ResourceType='healthcheck', ResourceType='healthcheck',