[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:
|
if not do_merge:
|
||||||
thing.attributes = attributes
|
thing.attributes = attributes
|
||||||
else:
|
else:
|
||||||
thing.attributes.update(attributes)
|
thing.attributes = {k: v for k, v in attributes.items() if v}
|
||||||
|
|
||||||
def create_keys_and_certificate(
|
def create_keys_and_certificate(
|
||||||
self, set_as_active: bool
|
self, set_as_active: bool
|
||||||
@ -1307,7 +1307,6 @@ class IoTBackend(BaseBackend):
|
|||||||
return thing_names
|
return thing_names
|
||||||
|
|
||||||
def list_thing_principals(self, thing_name: str) -> List[str]:
|
def list_thing_principals(self, thing_name: str) -> List[str]:
|
||||||
|
|
||||||
things = [_ for _ in self.things.values() if _.thing_name == thing_name]
|
things = [_ for _ in self.things.values() if _.thing_name == thing_name]
|
||||||
if len(things) == 0:
|
if len(things) == 0:
|
||||||
raise ResourceNotFoundException(
|
raise ResourceNotFoundException(
|
||||||
|
@ -54,6 +54,15 @@ def test_update_thing():
|
|||||||
assert res["things"][0]["thingArn"] is not None
|
assert res["things"][0]["thingArn"] is not None
|
||||||
assert res["things"][0]["attributes"]["k1"] == "v1"
|
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
|
@mock_iot
|
||||||
def test_describe_thing():
|
def test_describe_thing():
|
||||||
|
Loading…
Reference in New Issue
Block a user