diff --git a/src/python_testing/TestConformanceSupport.py b/src/python_testing/TestConformanceSupport.py index 788f1025a52fa3..b383f1acb63cc7 100644 --- a/src/python_testing/TestConformanceSupport.py +++ b/src/python_testing/TestConformanceSupport.py @@ -89,6 +89,15 @@ async def test_conformance_provisional(self): asserts.assert_equal(xml_callable(f, [], []), ConformanceDecision.PROVISIONAL) asserts.assert_equal(str(xml_callable), 'P') + @async_test_body + async def test_conformance_zigbee(self): + xml = '' + et = ElementTree.fromstring(xml) + xml_callable = parse_callable_from_xml(et, self.params) + for f in self.feature_maps: + asserts.assert_equal(xml_callable(f, [], []), ConformanceDecision.NOT_APPLICABLE) + asserts.assert_equal(str(xml_callable), 'Zigbee') + @async_test_body async def test_conformance_mandatory_on_condition(self): xml = ('' diff --git a/src/python_testing/conformance_support.py b/src/python_testing/conformance_support.py index 1d3f3128ef37cd..3cbef4150dd5b3 100644 --- a/src/python_testing/conformance_support.py +++ b/src/python_testing/conformance_support.py @@ -34,6 +34,7 @@ FEATURE_TAG = 'feature' ATTRIBUTE_TAG = 'attribute' COMMAND_TAG = 'command' +CONDITION_TAG = 'condition' class ConformanceException(Exception): @@ -67,6 +68,14 @@ def conformance_allowed(conformance_decision: ConformanceDecision, allow_provisi return True +class zigbee: + def __call__(self, feature_map: uint, attribute_list: list[uint], all_command_list: list[uint]) -> ConformanceDecision: + return ConformanceDecision.NOT_APPLICABLE + + def __str__(self): + return "Zigbee" + + class mandatory: def __call__(self, feature_map: uint, attribute_list: list[uint], all_command_list: list[uint]) -> ConformanceDecision: return ConformanceDecision.MANDATORY @@ -307,6 +316,8 @@ def parse_callable_from_xml(element: ElementTree.Element, params: ConformancePar raise ConformanceException(f'Conformance specifies attribute or command not in table: {name}') elif element.tag == COMMAND_TAG: return command(params.command_map[element.get('name')], element.get('name')) + elif element.tag == CONDITION_TAG and element.get('name').lower() == 'zigbee': + return zigbee() else: raise ConformanceException( f'Unexpected xml conformance element with no children {str(element.tag)} {str(element.attrib)}') diff --git a/src/python_testing/spec_parsing_support.py b/src/python_testing/spec_parsing_support.py index d437f04a825816..b59ef8379e9e63 100644 --- a/src/python_testing/spec_parsing_support.py +++ b/src/python_testing/spec_parsing_support.py @@ -78,22 +78,6 @@ class CommandType(Enum): GENERATED = auto() -def has_zigbee_conformance(conformance: ElementTree.Element) -> bool: - # For clusters, things with zigbee conformance can share IDs with the matter elements, so we don't want them - - # TODO: it's actually possible for a thing to have a zigbee conformance AND to have other conformances, and we should check - # for that, but for now, this is fine because that hasn't happened in the cluster conformances YET. - # It does happen for device types, so we need to be careful there. - condition = conformance.iter('condition') - for c in condition: - try: - c.attrib['name'].lower() == "zigbee" - return True - except KeyError: - continue - return False - - class ClusterParser: def __init__(self, cluster, cluster_id, name): self._problems: list[ProblemNotice] = [] @@ -150,8 +134,6 @@ def get_all_type(self, type_container: str, type_name: str, key_name: str) -> li # This is a conformance tag, which uses the same name continue conformance = self.get_conformance(element) - if has_zigbee_conformance(conformance): - continue ret.append((element, conformance)) return ret