Skip to content

Commit

Permalink
Fix TestWriteBasicAttributes for all cases
Browse files Browse the repository at this point in the history
It seems TestWriteBasicAttributes did not correctly write
the attributes. The broad exception handling seems to have hidden
this issue even.  Make sure the attributes with the correct value
get written, and check for unexpected and expected IM errors
in the per-attribute results specifically.
  • Loading branch information
agners committed May 14, 2024
1 parent 138a686 commit fd30b24
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/controller/python/test/test_scripts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,16 +1193,16 @@ class AttributeWriteRequest:
failed_attribute_write = []
for req in requests:
try:
try:
await self.devCtrl.WriteAttribute(nodeid, [(endpoint, req.attribute, 0)])
if req.expected_status != IM.Status.Success:
raise AssertionError(
f"Write attribute {req.attribute.__qualname__} expects failure but got success response")
except ChipStackError as ex:
if req.expected_status != IM.Status.Success:
continue
else:
raise ex
# Errors tested here is in the per-attribute result list (type AttributeStatus)
write_res = await self.devCtrl.WriteAttribute(nodeid, [(endpoint, req.attribute(req.value))])
status = write_res[0].Status
if req.expected_status != status:
raise AssertionError(
f"Write attribute {req.attribute.__qualname__} expects {req.expected_status} but got {status}")

# Only execute read tests where write is successful.
if req.expected_status != IM.Status.Success:
continue

res = await self.devCtrl.ReadAttribute(nodeid, [(endpoint, req.attribute)])
val = res[endpoint][req.cluster][req.attribute]
Expand Down

0 comments on commit fd30b24

Please sign in to comment.