[iot] update_thing(): empty attributes are deleted with merge=true (#6910)
This commit is contained in:
parent
f59e178f27
commit
44fe39f584
@ -883,7 +883,7 @@ class IoTBackend(BaseBackend):
|
||||
if not do_merge:
|
||||
thing.attributes = attributes
|
||||
else:
|
||||
thing.attributes.update(attributes)
|
||||
thing.attributes = {k: v for k, v in attributes.items() if v}
|
||||
|
||||
def create_keys_and_certificate(
|
||||
self, set_as_active: bool
|
||||
@ -1307,7 +1307,6 @@ class IoTBackend(BaseBackend):
|
||||
return thing_names
|
||||
|
||||
def list_thing_principals(self, thing_name: str) -> List[str]:
|
||||
|
||||
things = [_ for _ in self.things.values() if _.thing_name == thing_name]
|
||||
if len(things) == 0:
|
||||
raise ResourceNotFoundException(
|
||||
|
@ -54,6 +54,15 @@ def test_update_thing():
|
||||
assert res["things"][0]["thingArn"] is not None
|
||||
assert res["things"][0]["attributes"]["k1"] == "v1"
|
||||
|
||||
client.update_thing(
|
||||
thingName=name, attributePayload={"attributes": {"k1": ""}, "merge": True}
|
||||
)
|
||||
res = client.list_things()
|
||||
assert len(res["things"]) == 1
|
||||
assert res["things"][0]["thingName"] is not None
|
||||
assert res["things"][0]["thingArn"] is not None
|
||||
assert res["things"][0]["attributes"] == {}
|
||||
|
||||
|
||||
@mock_iot
|
||||
def test_describe_thing():
|
||||
|
Loading…
Reference in New Issue
Block a user