diff --git a/src/controller/python/test/test_scripts/base.py b/src/controller/python/test/test_scripts/base.py index 884a1a2ae58305..cf0245cc04ffe1 100644 --- a/src/controller/python/test/test_scripts/base.py +++ b/src/controller/python/test/test_scripts/base.py @@ -1201,45 +1201,42 @@ def TestReadBasicAttributes(self, nodeid: int, endpoint: int, group: int): return False return True - def TestWriteBasicAttributes(self, nodeid: int, endpoint: int, group: int): + def TestWriteBasicAttributes(self, nodeid: int, endpoint: int): @ dataclass class AttributeWriteRequest: - cluster: str - attribute: str + cluster: Clusters.ClusterObjects.Cluster + attribute: Clusters.ClusterObjects.ClusterAttributeDescriptor value: Any expected_status: IM.Status = IM.Status.Success requests = [ - AttributeWriteRequest("BasicInformation", "NodeLabel", "Test"), - AttributeWriteRequest("BasicInformation", "Location", + AttributeWriteRequest(Clusters.BasicInformation, Clusters.BasicInformation.Attributes.NodeLabel, "Test"), + AttributeWriteRequest(Clusters.BasicInformation, Clusters.BasicInformation.Attributes.Location, "a pretty loooooooooooooog string", IM.Status.ConstraintError), ] - failed_zcl = [] + failed_attribute_write = [] for req in requests: try: try: - self.devCtrl.ZCLWriteAttribute(cluster=req.cluster, - attribute=req.attribute, - nodeid=nodeid, - endpoint=endpoint, - groupid=group, - value=req.value) + await self.WriteAttribute(nodeid, [(endpoint, req.attribute, 0)]) if req.expected_status != IM.Status.Success: raise AssertionError( - f"Write attribute {req.cluster}.{req.attribute} expects failure but got success response") + f"Write attribute {req.attribute.__qualname__} expects failure but got success response") except Exception as ex: if req.expected_status != IM.Status.Success: continue else: raise ex - res = self.devCtrl.ZCLReadAttribute( - cluster=req.cluster, attribute=req.attribute, nodeid=nodeid, endpoint=endpoint, groupid=group) - TestResult(f"Read attribute {req.cluster}.{req.attribute}", res).assertValueEqual( - req.value) + + res = await self.ReadAttribute(nodeid, [(endpoint, req.attribute)]) + val = res[endpoint][req.cluster][req.attribute] + if val != req.value: + raise Exception( + f"Read attribute {req.attribute.__qualname__}: expected value {req.value}, got {val}") except Exception as ex: - failed_zcl.append(str(ex)) - if failed_zcl: - self.logger.exception(f"Following attributes failed: {failed_zcl}") + failed_attribute_write.append(str(ex)) + if failed_attribute_write: + self.logger.exception(f"Following attributes failed: {failed_attribute_write}") return False return True diff --git a/src/controller/python/test/test_scripts/mobile-device-test.py b/src/controller/python/test/test_scripts/mobile-device-test.py index a4c9e630e4bc04..cd8f664351f86a 100755 --- a/src/controller/python/test/test_scripts/mobile-device-test.py +++ b/src/controller/python/test/test_scripts/mobile-device-test.py @@ -130,8 +130,7 @@ def TestDatamodel(test: BaseTestHelper, device_nodeid: int): logger.info("Testing attribute writing") FailIfNot(test.TestWriteBasicAttributes(nodeid=device_nodeid, - endpoint=ENDPOINT_ID, - group=GROUP_ID), + endpoint=ENDPOINT_ID), "Failed to test Write Basic Attributes") logger.info("Testing attribute reading basic again")