11import pytest
22
3- from airbyte_cdk .utils .mapping_helpers import combine_mappings , _validate_multiple_request_options , RequestOption , RequestOptionType
3+ from airbyte_cdk .utils .mapping_helpers import (
4+ combine_mappings ,
5+ _validate_component_request_option_paths ,
6+ RequestOption ,
7+ RequestOptionType ,
8+ )
49
510
611@pytest .mark .parametrize (
@@ -119,13 +124,18 @@ def test_body_json_requests(test_name, mappings, expected_result, expected_error
119124def mock_config () -> dict [str , str ]:
120125 return {"test" : "config" }
121126
127+
122128@pytest .mark .parametrize (
123129 "test_name, option1, option2, should_raise" ,
124130 [
125131 (
126132 "different_fields" ,
127- RequestOption (field_name = "field1" , inject_into = RequestOptionType .body_json , parameters = {}),
128- RequestOption (field_name = "field2" , inject_into = RequestOptionType .body_json , parameters = {}),
133+ RequestOption (
134+ field_name = "field1" , inject_into = RequestOptionType .body_json , parameters = {}
135+ ),
136+ RequestOption (
137+ field_name = "field2" , inject_into = RequestOptionType .body_json , parameters = {}
138+ ),
129139 False ,
130140 ),
131141 (
@@ -136,41 +146,76 @@ def mock_config() -> dict[str, str]:
136146 ),
137147 (
138148 "different_nested_paths" ,
139- RequestOption (field_path = ["data" , "query1" , "limit" ], inject_into = RequestOptionType .body_json , parameters = {}),
140- RequestOption (field_path = ["data" , "query2" , "limit" ], inject_into = RequestOptionType .body_json , parameters = {}),
149+ RequestOption (
150+ field_path = ["data" , "query1" , "limit" ],
151+ inject_into = RequestOptionType .body_json ,
152+ parameters = {},
153+ ),
154+ RequestOption (
155+ field_path = ["data" , "query2" , "limit" ],
156+ inject_into = RequestOptionType .body_json ,
157+ parameters = {},
158+ ),
141159 False ,
142160 ),
143161 (
144162 "same_nested_paths" ,
145- RequestOption (field_path = ["data" , "query" , "limit" ], inject_into = RequestOptionType .body_json , parameters = {}),
146- RequestOption (field_path = ["data" , "query" , "limit" ], inject_into = RequestOptionType .body_json , parameters = {}),
163+ RequestOption (
164+ field_path = ["data" , "query" , "limit" ],
165+ inject_into = RequestOptionType .body_json ,
166+ parameters = {},
167+ ),
168+ RequestOption (
169+ field_path = ["data" , "query" , "limit" ],
170+ inject_into = RequestOptionType .body_json ,
171+ parameters = {},
172+ ),
147173 True ,
148174 ),
149175 (
150176 "different_inject_types" ,
151177 RequestOption (field_name = "field" , inject_into = RequestOptionType .header , parameters = {}),
152- RequestOption (field_name = "field" , inject_into = RequestOptionType .body_json , parameters = {}),
178+ RequestOption (
179+ field_name = "field" , inject_into = RequestOptionType .body_json , parameters = {}
180+ ),
153181 False ,
154182 ),
155- ]
183+ ],
156184)
157185def test_request_option_validation (test_name , option1 , option2 , should_raise , mock_config ):
158186 """Test various combinations of request option validation"""
159187 if should_raise :
160188 with pytest .raises (ValueError , match = "duplicate keys detected" ):
161- _validate_multiple_request_options (mock_config , option1 , option2 )
189+ _validate_component_request_option_paths (mock_config , option1 , option2 )
162190 else :
163- _validate_multiple_request_options (mock_config , option1 , option2 )
191+ _validate_component_request_option_paths (mock_config , option1 , option2 )
192+
164193
165194@pytest .mark .parametrize (
166195 "test_name, options" ,
167196 [
168- ("none_options" , [None , RequestOption (field_name = "field" , inject_into = RequestOptionType .header , parameters = {}), None ]),
169- ("single_option" , [RequestOption (field_name = "field" , inject_into = RequestOptionType .header , parameters = {})]),
197+ (
198+ "none_options" ,
199+ [
200+ None ,
201+ RequestOption (
202+ field_name = "field" , inject_into = RequestOptionType .header , parameters = {}
203+ ),
204+ None ,
205+ ],
206+ ),
207+ (
208+ "single_option" ,
209+ [
210+ RequestOption (
211+ field_name = "field" , inject_into = RequestOptionType .header , parameters = {}
212+ )
213+ ],
214+ ),
170215 ("all_none" , [None , None , None ]),
171216 ("empty_list" , []),
172- ]
217+ ],
173218)
174219def test_edge_cases (test_name , options , mock_config ):
175220 """Test edge cases like None values and single options"""
176- _validate_multiple_request_options (mock_config , * options )
221+ _validate_component_request_option_paths (mock_config , * options )
0 commit comments