1
1
import pytest
2
2
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
+ )
4
9
5
10
6
11
@pytest .mark .parametrize (
@@ -119,13 +124,18 @@ def test_body_json_requests(test_name, mappings, expected_result, expected_error
119
124
def mock_config () -> dict [str , str ]:
120
125
return {"test" : "config" }
121
126
127
+
122
128
@pytest .mark .parametrize (
123
129
"test_name, option1, option2, should_raise" ,
124
130
[
125
131
(
126
132
"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
+ ),
129
139
False ,
130
140
),
131
141
(
@@ -136,41 +146,76 @@ def mock_config() -> dict[str, str]:
136
146
),
137
147
(
138
148
"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
+ ),
141
159
False ,
142
160
),
143
161
(
144
162
"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
+ ),
147
173
True ,
148
174
),
149
175
(
150
176
"different_inject_types" ,
151
177
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
+ ),
153
181
False ,
154
182
),
155
- ]
183
+ ],
156
184
)
157
185
def test_request_option_validation (test_name , option1 , option2 , should_raise , mock_config ):
158
186
"""Test various combinations of request option validation"""
159
187
if should_raise :
160
188
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 )
162
190
else :
163
- _validate_multiple_request_options (mock_config , option1 , option2 )
191
+ _validate_component_request_option_paths (mock_config , option1 , option2 )
192
+
164
193
165
194
@pytest .mark .parametrize (
166
195
"test_name, options" ,
167
196
[
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
+ ),
170
215
("all_none" , [None , None , None ]),
171
216
("empty_list" , []),
172
- ]
217
+ ],
173
218
)
174
219
def test_edge_cases (test_name , options , mock_config ):
175
220
"""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