66 tests:
77 spec: [...]
88 connection: [...]
9-
9+
1010To the new format:
1111 acceptance_tests:
1212 spec:
1515 tests: [...]
1616"""
1717
18- import yaml
1918import sys
2019from pathlib import Path
21- from typing import Dict , Any
20+ from typing import Any , Dict
21+
22+ import yaml
2223
2324
2425class FixingListIndentationDumper (yaml .Dumper ):
@@ -38,53 +39,59 @@ class FixingListIndentationDumper(yaml.Dumper):
3839 ```
3940
4041 """
42+
4143 def increase_indent (self , flow = False , indentless = False ):
4244 return super (FixingListIndentationDumper , self ).increase_indent (flow , False )
4345
4446
4547class AlreadyUpdatedError (Exception ):
4648 """Exception raised when the YAML file has already been updated."""
49+
4750 pass
4851
4952
5053def transform (file_path : Path ) -> None :
51- with open (file_path , 'r' ) as f :
54+ with open (file_path , "r" ) as f :
5255 data = yaml .safe_load (f )
53-
54- if ' acceptance_tests' in data :
56+
57+ if " acceptance_tests" in data :
5558 raise AlreadyUpdatedError ()
5659
57- if ' tests' not in data :
60+ if " tests" not in data :
5861 raise ValueError (f"No 'tests' key found in { file_path } , skipping transformation" )
59-
62+
6063 # Extract the tests data
61- tests_data = data .pop (' tests' )
62-
64+ tests_data = data .pop (" tests" )
65+
6366 if not isinstance (tests_data , dict ):
6467 raise ValueError (f"Error: 'tests' key in { file_path } is not a dictionary" )
65-
68+
6669 # Create the new acceptance_tests structure
67- data [' acceptance_tests' ] = {}
68-
70+ data [" acceptance_tests" ] = {}
71+
6972 # Transform each test type
7073 for test_type , test_content in tests_data .items ():
71- data [' acceptance_tests' ][test_type ] = {' tests' : test_content }
72-
74+ data [" acceptance_tests" ][test_type ] = {" tests" : test_content }
75+
7376 # Write back to file with preserved formatting
74- with open (file_path , 'w' ) as f :
75- yaml .dump (data , f , Dumper = FixingListIndentationDumper , default_flow_style = False , sort_keys = False )
76-
77+ with open (file_path , "w" ) as f :
78+ yaml .dump (
79+ data , f , Dumper = FixingListIndentationDumper , default_flow_style = False , sort_keys = False
80+ )
81+
7782 print (f"Successfully transformed { file_path } " )
7883
7984
8085def main ():
8186 if len (sys .argv ) != 2 :
8287 print ("Usage: python fix_acceptance_tests_yml.py <airbyte_repo_path>" )
8388 sys .exit (1 )
84-
89+
8590 repo_path = Path (sys .argv [1 ])
8691
87- for file_path in repo_path .glob ('airbyte-integrations/connectors/source-*/acceptance-test-config.yml' ):
92+ for file_path in repo_path .glob (
93+ "airbyte-integrations/connectors/source-*/acceptance-test-config.yml"
94+ ):
8895 try :
8996 transform (file_path )
9097 except AlreadyUpdatedError :
0 commit comments