Skip to content

Commit

Permalink
Make zigbee a real conformance (#30075)
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille authored and pull[bot] committed Dec 4, 2023
1 parent d9f036e commit 1029702
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
9 changes: 9 additions & 0 deletions src/python_testing/TestConformanceSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<condition name="Zigbee"/>'
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 = ('<mandatoryConform>'
Expand Down
11 changes: 11 additions & 0 deletions src/python_testing/conformance_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
FEATURE_TAG = 'feature'
ATTRIBUTE_TAG = 'attribute'
COMMAND_TAG = 'command'
CONDITION_TAG = 'condition'


class ConformanceException(Exception):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)}')
Expand Down
18 changes: 0 additions & 18 deletions src/python_testing/spec_parsing_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 1029702

Please sign in to comment.