22
22
import logging
23
23
import pathlib
24
24
import sys
25
+ import typing
25
26
from pprint import pprint
26
27
from typing import Any , Optional
27
28
@@ -97,6 +98,16 @@ def ConvertValue(value) -> Any:
97
98
98
99
99
100
class BasicCompositionTests :
101
+ def dump_wildcard (self , dump_device_composition_path : typing .Optional [str ]):
102
+ node_dump_dict = {endpoint_id : MatterTlvToJson (self .endpoints_tlv [endpoint_id ]) for endpoint_id in self .endpoints_tlv }
103
+ logging .debug (f"Raw TLV contents of Node: { json .dumps (node_dump_dict , indent = 2 )} " )
104
+
105
+ if dump_device_composition_path is not None :
106
+ with open (pathlib .Path (dump_device_composition_path ).with_suffix (".json" ), "wt+" ) as outfile :
107
+ json .dump (node_dump_dict , outfile , indent = 2 )
108
+ with open (pathlib .Path (dump_device_composition_path ).with_suffix (".txt" ), "wt+" ) as outfile :
109
+ pprint (self .endpoints , outfile , indent = 1 , width = 200 , compact = True )
110
+
100
111
async def setup_class_helper (self , default_to_pase : bool = True ):
101
112
dev_ctrl = self .default_controller
102
113
self .problems = []
@@ -114,29 +125,20 @@ async def setup_class_helper(self, default_to_pase: bool = True):
114
125
node_id = self .dut_node_id
115
126
116
127
wildcard_read = (await dev_ctrl .Read (node_id , [()]))
117
- endpoints_tlv = wildcard_read .tlvAttributes
118
-
119
- node_dump_dict = {endpoint_id : MatterTlvToJson (endpoints_tlv [endpoint_id ]) for endpoint_id in endpoints_tlv }
120
- logging .debug (f"Raw TLV contents of Node: { json .dumps (node_dump_dict , indent = 2 )} " )
121
-
122
- if dump_device_composition_path is not None :
123
- with open (pathlib .Path (dump_device_composition_path ).with_suffix (".json" ), "wt+" ) as outfile :
124
- json .dump (node_dump_dict , outfile , indent = 2 )
125
- with open (pathlib .Path (dump_device_composition_path ).with_suffix (".txt" ), "wt+" ) as outfile :
126
- pprint (wildcard_read .attributes , outfile , indent = 1 , width = 200 , compact = True )
127
-
128
- logging .info ("###########################################################" )
129
- logging .info ("Start of actual tests" )
130
- logging .info ("###########################################################" )
131
128
132
129
# ======= State kept for use by all tests =======
133
-
134
130
# All endpoints in "full object" indexing format
135
131
self .endpoints = wildcard_read .attributes
136
132
137
133
# All endpoints in raw TLV format
138
134
self .endpoints_tlv = wildcard_read .tlvAttributes
139
135
136
+ self .dump_wildcard (dump_device_composition_path )
137
+
138
+ logging .info ("###########################################################" )
139
+ logging .info ("Start of actual tests" )
140
+ logging .info ("###########################################################" )
141
+
140
142
def get_test_name (self ) -> str :
141
143
"""Return the function name of the caller. Used to create logging entries."""
142
144
return sys ._getframe ().f_back .f_code .co_name
0 commit comments