Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python testing: Make a function to get the cluster object from the attribute/command objects #34998

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/python_testing/matter_testing_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,14 @@ def whole_node_runner(self: MatterBaseTest, *args, **kwargs):
EndpointCheckFunction = typing.Callable[[Clusters.Attribute.AsyncReadTransaction.ReadResponse, int], bool]


def get_cluster_from_attribute(attribute: ClusterObjects.ClusterAttributeDescriptor) -> ClusterObjects.Cluster:
return ClusterObjects.ALL_CLUSTERS[attribute.cluster_id]


def get_cluster_from_command(command: ClusterObjects.ClusterCommand) -> ClusterObjects.Cluster:
return ClusterObjects.ALL_CLUSTERS[command.cluster_id]


def _has_cluster(wildcard, endpoint, cluster: ClusterObjects.Cluster) -> bool:
try:
return cluster in wildcard.attributes[endpoint]
Expand Down Expand Up @@ -1795,7 +1803,7 @@ def has_cluster(cluster: ClusterObjects.ClusterObjectDescriptor) -> EndpointChec


def _has_attribute(wildcard, endpoint, attribute: ClusterObjects.ClusterAttributeDescriptor) -> bool:
cluster = getattr(Clusters, attribute.__qualname__.split('.')[-3])
cluster = get_cluster_from_attribute(attribute)
try:
attr_list = wildcard.attributes[endpoint][cluster][cluster.Attributes.AttributeList]
return attribute.attribute_id in attr_list
Expand Down
Loading