From f47d9eefefdee0376f12367003854910fb05df79 Mon Sep 17 00:00:00 2001 From: Jonas Date: Wed, 27 Jul 2022 12:03:26 +0200 Subject: [PATCH] IOT: update thing group descriptions (#5298) --- moto/iot/models.py | 4 ++++ tests/test_iot/test_iot_thing_groups.py | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/moto/iot/models.py b/moto/iot/models.py index 899787651..713d02d27 100644 --- a/moto/iot/models.py +++ b/moto/iot/models.py @@ -1311,6 +1311,10 @@ class IoTBackend(BaseBackend): ].update(attributes) elif attribute_payload is not None and "attributes" not in attribute_payload: thing_group.attributes = {} + if "thingGroupDescription" in thing_group_properties: + thing_group.thing_group_properties[ + "thingGroupDescription" + ] = thing_group_properties["thingGroupDescription"] thing_group.version = thing_group.version + 1 return thing_group.version diff --git a/tests/test_iot/test_iot_thing_groups.py b/tests/test_iot/test_iot_thing_groups.py index 5f4a459cd..d5b08daaa 100644 --- a/tests/test_iot/test_iot_thing_groups.py +++ b/tests/test_iot/test_iot_thing_groups.py @@ -594,3 +594,24 @@ def test_thing_group_already_exists_with_same_properties_returned(): thingGroupName=thing_group_name, thingGroupProperties=thing_group_properties ) assert thing_group == current_thing_group + + +@mock_iot +def test_thing_group_updates_description(): + client = boto3.client("iot", region_name="ap-northeast-1") + name = "my-thing-group" + new_description = "new description" + client.create_thing_group( + thingGroupName=name, + thingGroupProperties={"thingGroupDescription": "initial-description"}, + ) + + client.update_thing_group( + thingGroupName=name, + thingGroupProperties={"thingGroupDescription": new_description}, + ) + + thing_group = client.describe_thing_group(thingGroupName=name) + thing_group.should.have.key("thingGroupProperties").which.should.have.key( + "thingGroupDescription" + ).which.should.equal(new_description)