File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Created on 2025-01-17
3+
4+ @author: wf
5+ """
6+ import json
7+ from ngwidgets .basetest import Basetest
8+ from ngwidgets .mbus_viewer import MBusParser
9+
10+ class TestMBusParser (Basetest ):
11+ """
12+ test MBusParser
13+ """
14+
15+ def setUp (self , debug = True , profile = True ):
16+ Basetest .setUp (self , debug = debug , profile = profile )
17+
18+ def test_mbus_parser (self ):
19+ """
20+ Test examples from MBusParser class
21+ """
22+ mbus_parser = MBusParser ()
23+ for name , hex_data in mbus_parser .examples .items ():
24+ error_msg ,json_str = mbus_parser .parse_mbus_data (hex_data )
25+ if self .debug :
26+ marker = "✗" if error_msg else "✓"
27+ print (f"{ name } { marker } " )
28+ if error_msg :
29+ print (error_msg )
30+ else :
31+ json_data = json .loads (json_str )
32+ print (json .dumps (json_data ,indent = 2 ))
33+
34+ self .assertIsNone (error_msg , f"Failed to parse { name } " )
35+ self .assertIsInstance (json_data , dict )
You can’t perform that action at this time.
0 commit comments