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):
if 'Tag' in tags:
for key, tag in tags.items():
for t in tag:
self.resource_tags[resource_id][t['Key']] = t['Value']
if isinstance(tags['Tag'], list):
for tag in tags['Tag']:
self.resource_tags[resource_id][tag['Key']] = tag['Value']
else:
key, value = (tags['Tag']['Key'], tags['Tag']['Value'])
self.resource_tags[resource_id][key] = value
else:
for _, keys in tags.items():
if isinstance(keys, list):
for key in keys:
if 'Key' in tags:
if isinstance(tags['Key'], list):
for key in tags['Key']:
del(self.resource_tags[resource_id][key])
else:
del(self.resource_tags[resource_id][keys])
del(self.resource_tags[resource_id][tags['Key']])
def list_tags_for_resource(self, resource_id):
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(tag2)
len(response['ResourceTagSet']['Tags']).should.equal(2)
# Try to remove the tags
conn.change_tags_for_resource(
ResourceType='healthcheck',