Skip to content

Commit

Permalink
support optinoally writeable attributes in test
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Jan 16, 2024
1 parent aa8f644 commit 950ecce
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/python_testing/TC_AccessChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ async def _run_read_access_test_for_cluster_privilege(self, endpoint_id, cluster
async def _run_write_access_test_for_cluster_privilege(self, endpoint_id, cluster_id, cluster, xml_cluster: XmlCluster, privilege: Clusters.AccessControl.Enums.AccessControlEntryPrivilegeEnum, wildcard_read):
for attribute_id in checkable_attributes(cluster_id, cluster, xml_cluster):
spec_requires = xml_cluster.attributes[attribute_id].write_access
is_optional_write = xml_cluster.attributes[attribute_id].write_optional

attribute = Clusters.ClusterObjects.ALL_ATTRIBUTES[cluster_id][attribute_id]
cluster_class = Clusters.ClusterObjects.ALL_CLUSTERS[cluster_id]
Expand All @@ -155,7 +156,7 @@ async def _run_write_access_test_for_cluster_privilege(self, endpoint_id, cluste
# This will only not work if we end up with write-only attributes. We do not currently have any of these.
val = wildcard_read.attributes[endpoint_id][cluster_class][attribute]
if isinstance(val, list):
# TODO: does this need a tracking issue? When we attempt to write a list that's too big, it fails.
# Use an empty list for writes in case the list is large and does not fit
val = []

resp = await self.TH2.WriteAttribute(nodeid=self.dut_node_id, attributes=[(endpoint_id, attribute(val))])
Expand All @@ -179,8 +180,8 @@ async def _run_write_access_test_for_cluster_privilege(self, endpoint_id, cluste
problem="Unexpected UnsupportedAccess writing attribute")
self.success = False
else:
# TODO: handle optionally writeable attributes in here.
if resp[0].Status != Status.UnsupportedAccess:
ok = (is_optional_write and resp[0].Status == Status.UnsupportedWrite) or resp[0].Status == Status.UnsupportedAccess
if not ok:
self.record_error(test_name=test_name, location=location,
problem=f"Unexpected error writing attribute - expected Unsupported Access, got {resp[0].Status}")
self.success = False
Expand Down

0 comments on commit 950ecce

Please sign in to comment.