Skip to content

Commit 2046576

Browse files
cecillepull[bot]
authored andcommitted
Make zigbee a real conformance (#30075)
1 parent 7d98b54 commit 2046576

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

src/python_testing/TestConformanceSupport.py

+9
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ async def test_conformance_provisional(self):
8989
asserts.assert_equal(xml_callable(f, [], []), ConformanceDecision.PROVISIONAL)
9090
asserts.assert_equal(str(xml_callable), 'P')
9191

92+
@async_test_body
93+
async def test_conformance_zigbee(self):
94+
xml = '<condition name="Zigbee"/>'
95+
et = ElementTree.fromstring(xml)
96+
xml_callable = parse_callable_from_xml(et, self.params)
97+
for f in self.feature_maps:
98+
asserts.assert_equal(xml_callable(f, [], []), ConformanceDecision.NOT_APPLICABLE)
99+
asserts.assert_equal(str(xml_callable), 'Zigbee')
100+
92101
@async_test_body
93102
async def test_conformance_mandatory_on_condition(self):
94103
xml = ('<mandatoryConform>'

src/python_testing/conformance_support.py

+11
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
FEATURE_TAG = 'feature'
3535
ATTRIBUTE_TAG = 'attribute'
3636
COMMAND_TAG = 'command'
37+
CONDITION_TAG = 'condition'
3738

3839

3940
class ConformanceException(Exception):
@@ -67,6 +68,14 @@ def conformance_allowed(conformance_decision: ConformanceDecision, allow_provisi
6768
return True
6869

6970

71+
class zigbee:
72+
def __call__(self, feature_map: uint, attribute_list: list[uint], all_command_list: list[uint]) -> ConformanceDecision:
73+
return ConformanceDecision.NOT_APPLICABLE
74+
75+
def __str__(self):
76+
return "Zigbee"
77+
78+
7079
class mandatory:
7180
def __call__(self, feature_map: uint, attribute_list: list[uint], all_command_list: list[uint]) -> ConformanceDecision:
7281
return ConformanceDecision.MANDATORY
@@ -307,6 +316,8 @@ def parse_callable_from_xml(element: ElementTree.Element, params: ConformancePar
307316
raise ConformanceException(f'Conformance specifies attribute or command not in table: {name}')
308317
elif element.tag == COMMAND_TAG:
309318
return command(params.command_map[element.get('name')], element.get('name'))
319+
elif element.tag == CONDITION_TAG and element.get('name').lower() == 'zigbee':
320+
return zigbee()
310321
else:
311322
raise ConformanceException(
312323
f'Unexpected xml conformance element with no children {str(element.tag)} {str(element.attrib)}')

src/python_testing/spec_parsing_support.py

-18
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,6 @@ class CommandType(Enum):
7878
GENERATED = auto()
7979

8080

81-
def has_zigbee_conformance(conformance: ElementTree.Element) -> bool:
82-
# For clusters, things with zigbee conformance can share IDs with the matter elements, so we don't want them
83-
84-
# TODO: it's actually possible for a thing to have a zigbee conformance AND to have other conformances, and we should check
85-
# for that, but for now, this is fine because that hasn't happened in the cluster conformances YET.
86-
# It does happen for device types, so we need to be careful there.
87-
condition = conformance.iter('condition')
88-
for c in condition:
89-
try:
90-
c.attrib['name'].lower() == "zigbee"
91-
return True
92-
except KeyError:
93-
continue
94-
return False
95-
96-
9781
class ClusterParser:
9882
def __init__(self, cluster, cluster_id, name):
9983
self._problems: list[ProblemNotice] = []
@@ -150,8 +134,6 @@ def get_all_type(self, type_container: str, type_name: str, key_name: str) -> li
150134
# This is a conformance tag, which uses the same name
151135
continue
152136
conformance = self.get_conformance(element)
153-
if has_zigbee_conformance(conformance):
154-
continue
155137
ret.append((element, conformance))
156138
return ret
157139

0 commit comments

Comments
 (0)