@@ -1201,45 +1201,42 @@ def TestReadBasicAttributes(self, nodeid: int, endpoint: int, group: int):
1201
1201
return False
1202
1202
return True
1203
1203
1204
- def TestWriteBasicAttributes (self , nodeid : int , endpoint : int , group : int ):
1204
+ async def TestWriteBasicAttributes (self , nodeid : int , endpoint : int ):
1205
1205
@ dataclass
1206
1206
class AttributeWriteRequest :
1207
- cluster : str
1208
- attribute : str
1207
+ cluster : Clusters . ClusterObjects . Cluster
1208
+ attribute : Clusters . ClusterObjects . ClusterAttributeDescriptor
1209
1209
value : Any
1210
1210
expected_status : IM .Status = IM .Status .Success
1211
1211
1212
1212
requests = [
1213
- AttributeWriteRequest (" BasicInformation" , " NodeLabel" , "Test" ),
1214
- AttributeWriteRequest (" BasicInformation" , " Location" ,
1213
+ AttributeWriteRequest (Clusters . BasicInformation , Clusters . BasicInformation . Attributes . NodeLabel , "Test" ),
1214
+ AttributeWriteRequest (Clusters . BasicInformation , Clusters . BasicInformation . Attributes . Location ,
1215
1215
"a pretty loooooooooooooog string" , IM .Status .ConstraintError ),
1216
1216
]
1217
- failed_zcl = []
1217
+ failed_attribute_write = []
1218
1218
for req in requests :
1219
1219
try :
1220
1220
try :
1221
- self .devCtrl .ZCLWriteAttribute (cluster = req .cluster ,
1222
- attribute = req .attribute ,
1223
- nodeid = nodeid ,
1224
- endpoint = endpoint ,
1225
- groupid = group ,
1226
- value = req .value )
1221
+ await self .WriteAttribute (nodeid , [(endpoint , req .attribute , 0 )])
1227
1222
if req .expected_status != IM .Status .Success :
1228
1223
raise AssertionError (
1229
- f"Write attribute { req .cluster } . { req . attribute } expects failure but got success response" )
1224
+ f"Write attribute { req .attribute . __qualname__ } expects failure but got success response" )
1230
1225
except Exception as ex :
1231
1226
if req .expected_status != IM .Status .Success :
1232
1227
continue
1233
1228
else :
1234
1229
raise ex
1235
- res = self .devCtrl .ZCLReadAttribute (
1236
- cluster = req .cluster , attribute = req .attribute , nodeid = nodeid , endpoint = endpoint , groupid = group )
1237
- TestResult (f"Read attribute { req .cluster } .{ req .attribute } " , res ).assertValueEqual (
1238
- req .value )
1230
+
1231
+ res = await self .ReadAttribute (nodeid , [(endpoint , req .attribute )])
1232
+ val = res [endpoint ][req .cluster ][req .attribute ]
1233
+ if val != req .value :
1234
+ raise Exception (
1235
+ f"Read attribute { req .attribute .__qualname__ } : expected value { req .value } , got { val } " )
1239
1236
except Exception as ex :
1240
- failed_zcl .append (str (ex ))
1241
- if failed_zcl :
1242
- self .logger .exception (f"Following attributes failed: { failed_zcl } " )
1237
+ failed_attribute_write .append (str (ex ))
1238
+ if failed_attribute_write :
1239
+ self .logger .exception (f"Following attributes failed: { failed_attribute_write } " )
1243
1240
return False
1244
1241
return True
1245
1242
0 commit comments