22
33import os
44import sys
5- from pathlib import Path
65
7- import asn1tools
6+ script_dir = os .path .dirname (os .path .abspath (__file__ ))
7+ sys .path .append (os .path .abspath (os .path .join (script_dir , '../jam-types-asn' )))
88
9- sys .path .append (os .path .abspath (os .path .join (os .path .dirname (__file__ ), '../jam-types-asn' )))
10- from utils import get_schema_files , validate
9+ from utils import validate_group # noqa: E402
1110
11+ os .chdir (script_dir )
1212
1313# Makes the SEQUENCE of OPTIONAL values ASN.1 compliant (using CHOICE)
1414def tweak_assignments_sequence_of_options (state_obj ):
@@ -19,21 +19,10 @@ def tweak_assignments_sequence_of_options(state_obj):
1919 else :
2020 items [i ] = {"some" : items [i ]}
2121
22-
2322def tweak_callback (json_obj ):
2423 tweak_assignments_sequence_of_options (json_obj ['pre_state' ])
2524 tweak_assignments_sequence_of_options (json_obj ['post_state' ])
2625 return json_obj
2726
28-
29- # Validate tiny
30- schema = asn1tools .compile_files (get_schema_files (False ) + ["assurances.asn" ], codec = "jer" )
31- for path in Path ("tiny" ).iterdir ():
32- if path .is_file () and path .suffix == ".json" :
33- validate (schema , path , "TestCase" , tweak_callback )
34-
35- # Validate full
36- schema = asn1tools .compile_files (get_schema_files (True ) + ["assurances.asn" ], codec = "jer" )
37- for path in Path ("full" ).iterdir ():
38- if path .is_file () and path .suffix == ".json" :
39- validate (schema , path , "TestCase" , tweak_callback )
27+ for spec in ["tiny" , "full" ]:
28+ validate_group ("assurances" , "assurances.asn" , spec , tweak_callback )
0 commit comments