Skip to content

Commit 00bd828

Browse files
TC-DESC-2.2: Fix comparison when mfg label is in the list (#35849)
* TC-DESC-2.2: Fix comparison when mfg label is in the list Unit tests included, also tested on an example app with mfg tags * linter * Restyled by isort --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 1f4e81e commit 00bd828

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/python_testing/TestMatterTestingSupport.py

+8
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,14 @@ def test_tag_list_problems(self):
549549
problems = find_tag_list_problems(roots, device_types, simple)
550550
asserts.assert_equal(len(problems), 0, "Unexpected problems found in list")
551551

552+
# Tags with mfg tags
553+
tag_mfg = Clusters.Descriptor.Structs.SemanticTagStruct(mfgCode=0xFFF1, label="test")
554+
tag_label = Clusters.Descriptor.Structs.SemanticTagStruct(tag=1, label="test")
555+
simple[1][Clusters.Descriptor][Clusters.Descriptor.Attributes.TagList] = [tag1, tag_mfg]
556+
simple[2][Clusters.Descriptor][Clusters.Descriptor.Attributes.TagList] = [tag1, tag_label]
557+
problems = find_tag_list_problems(roots, device_types, simple)
558+
asserts.assert_equal(len(problems), 0, "Unexpected problems found in list")
559+
552560
def test_root_node_tag_list_functions(self):
553561
# Example topology - see comment above for the layout.
554562
# There are 4 direct children of root 0

src/python_testing/matter_testing_infrastructure/chip/testing/taglist_and_topology_test.py

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from typing import Any
2222

2323
import chip.clusters as Clusters
24+
from chip.clusters.Types import Nullable
2425

2526

2627
@dataclass
@@ -143,12 +144,16 @@ def create_device_type_list_for_root(direct_children, endpoint_dict: dict[int, A
143144

144145

145146
def cmp_tag_list(a: Clusters.Descriptor.Structs.SemanticTagStruct, b: Clusters.Descriptor.Structs.SemanticTagStruct):
147+
if type(a.mfgCode) != type(b.mfgCode):
148+
return -1 if type(a.mfgCode) is Nullable else 1
146149
if a.mfgCode != b.mfgCode:
147150
return -1 if a.mfgCode < b.mfgCode else 1
148151
if a.namespaceID != b.namespaceID:
149152
return -1 if a.namespaceID < b.namespaceID else 1
150153
if a.tag != b.tag:
151154
return -1 if a.tag < b.tag else 1
155+
if type(a.label) != type(b.label):
156+
return -1 if type(a.label) is Nullable or a.label is None else 1
152157
if a.label != b.label:
153158
return -1 if a.label < b.label else 1
154159
return 0

0 commit comments

Comments
 (0)