iot:DeleteThingGroup should return success even for non-existent groups (#3367)

Closes #3026
This commit is contained in:
Brian Pandola 2020-10-09 07:57:00 -07:00 committed by GitHub
parent c1b2c78db2
commit db7842653f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -924,8 +924,12 @@ class IoTBackend(BaseBackend):
+ thing_group_name
+ " when there are still child groups attached to it"
)
thing_group = self.describe_thing_group(thing_group_name)
del self.thing_groups[thing_group.arn]
try:
thing_group = self.describe_thing_group(thing_group_name)
del self.thing_groups[thing_group.arn]
except ResourceNotFoundException:
# AWS returns success even if the thing group does not exist.
pass
def list_thing_groups(self, parent_group, name_prefix_filter, recursive):
if recursive is None:

View File

@ -1038,11 +1038,15 @@ def test_delete_thing_group():
res.should.have.key("thingGroups").which.should.have.length_of(1)
res["thingGroups"].should_not.have.key(group_name_2a)
# now that there is no child group, we can delete the previus group safely
# now that there is no child group, we can delete the previous group safely
client.delete_thing_group(thingGroupName=group_name_1a)
res = client.list_thing_groups()
res.should.have.key("thingGroups").which.should.have.length_of(0)
# Deleting an invalid thing group does not raise an error.
res = client.delete_thing_group(thingGroupName="non-existent-group-name")
res["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
@mock_iot
def test_describe_thing_group_metadata_hierarchy():