iot:DeleteThingGroup
should return success even for non-existent groups (#3367)
Closes #3026
This commit is contained in:
parent
c1b2c78db2
commit
db7842653f
@ -924,8 +924,12 @@ class IoTBackend(BaseBackend):
|
|||||||
+ thing_group_name
|
+ thing_group_name
|
||||||
+ " when there are still child groups attached to it"
|
+ " when there are still child groups attached to it"
|
||||||
)
|
)
|
||||||
thing_group = self.describe_thing_group(thing_group_name)
|
try:
|
||||||
del self.thing_groups[thing_group.arn]
|
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):
|
def list_thing_groups(self, parent_group, name_prefix_filter, recursive):
|
||||||
if recursive is None:
|
if recursive is None:
|
||||||
|
@ -1038,11 +1038,15 @@ def test_delete_thing_group():
|
|||||||
res.should.have.key("thingGroups").which.should.have.length_of(1)
|
res.should.have.key("thingGroups").which.should.have.length_of(1)
|
||||||
res["thingGroups"].should_not.have.key(group_name_2a)
|
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)
|
client.delete_thing_group(thingGroupName=group_name_1a)
|
||||||
res = client.list_thing_groups()
|
res = client.list_thing_groups()
|
||||||
res.should.have.key("thingGroups").which.should.have.length_of(0)
|
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
|
@mock_iot
|
||||||
def test_describe_thing_group_metadata_hierarchy():
|
def test_describe_thing_group_metadata_hierarchy():
|
||||||
|
Loading…
Reference in New Issue
Block a user