File tree Expand file tree Collapse file tree 2 files changed +24
-11
lines changed Expand file tree Collapse file tree 2 files changed +24
-11
lines changed Original file line number Diff line number Diff line change 3
3
4
4
import pytest
5
5
6
+ chip_cache = {}
6
7
7
- def validate_alt_mode (data ):
8
- # name = data["name"]
9
- mode_type = data .get ("type" , "" )
10
8
11
- assert mode_type != ""
12
- assert not mode_type .endswith ("?" )
9
+ def chip_path (chip ):
10
+ return f"chips/{ chip } .json"
11
+
12
+
13
+ def get_chip (chip ):
14
+ if chip not in chip_cache :
15
+ chip_cache [chip ] = json .load (open (chip_path (chip )))
16
+
17
+ return chip_cache [chip ]
13
18
14
19
15
20
def validate_pin (data ):
16
- alt_modes = data .get ("alt_modes" , [])
21
+ chip = get_chip (data ["chip" ])
22
+ path = chip_path (data ["chip" ])
23
+ signal = data ["signal" ]
17
24
18
- for alt_mode in alt_modes :
19
- validate_alt_mode ( alt_mode )
25
+ if signal not in chip [ "signals" ] :
26
+ raise AssertionError ( f"Signal { signal } not found in { path } " )
20
27
21
28
22
29
def validate_header (data ):
@@ -32,7 +39,7 @@ def validate_header(data):
32
39
validate_pin (pin )
33
40
34
41
35
- @pytest .mark .parametrize (' board_file' , glob .glob ("boards/*.json" ))
42
+ @pytest .mark .parametrize (" board_file" , glob .glob ("boards/*.json" ))
36
43
def test_validate_board_json_files (board_file ):
37
44
data = json .load (open (board_file , "r" ))
38
45
Original file line number Diff line number Diff line change 4
4
import pytest
5
5
from jsonschema import validate
6
6
7
- from schema import board
7
+ from schema .board import board
8
+ from schema .chip import chip
8
9
9
10
10
- @pytest .mark .parametrize (' board_file' , glob .glob ("boards/*.json" ))
11
+ @pytest .mark .parametrize (" board_file" , glob .glob ("boards/*.json" ))
11
12
def test_validate_board_json_schema (board_file ):
12
13
validate (instance = json .load (open (board_file , "r" )), schema = board )
14
+
15
+
16
+ @pytest .mark .parametrize ("chip_file" , glob .glob ("chips/*.json" ))
17
+ def test_validate_chip_json_schema (chip_file ):
18
+ validate (instance = json .load (open (chip_file , "r" )), schema = chip )
You can’t perform that action at this time.
0 commit comments