Skip to content

Commit fdfd154

Browse files
committed
chore: update method name
1 parent 5614a91 commit fdfd154

File tree

3 files changed

+71
-21
lines changed

3 files changed

+71
-21
lines changed

airbyte_cdk/sources/declarative/incremental/datetime_based_cursor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
)
2222
from airbyte_cdk.sources.message import MessageRepository
2323
from airbyte_cdk.sources.types import Config, Record, StreamSlice, StreamState
24-
from airbyte_cdk.utils.mapping_helpers import _validate_multiple_request_options
24+
from airbyte_cdk.utils.mapping_helpers import _validate_component_request_option_paths
2525

2626

2727
@dataclass
@@ -122,8 +122,10 @@ def __post_init__(self, parameters: Mapping[str, Any]) -> None:
122122

123123
if not self.cursor_datetime_formats:
124124
self.cursor_datetime_formats = [self.datetime_format]
125-
126-
_validate_multiple_request_options(self.config, self.start_time_option, self.end_time_option)
125+
126+
_validate_component_request_option_paths(
127+
self.config, self.start_time_option, self.end_time_option
128+
)
127129

128130
def get_stream_state(self) -> StreamState:
129131
return {self.cursor_field.eval(self.config): self._cursor} if self._cursor else {} # type: ignore # cursor_field is converted to an InterpolatedString in __post_init__

airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
)
2424
from airbyte_cdk.sources.declarative.requesters.request_path import RequestPath
2525
from airbyte_cdk.sources.types import Config, Record, StreamSlice, StreamState
26-
from airbyte_cdk.utils.mapping_helpers import combine_mappings, _validate_multiple_request_options
26+
from airbyte_cdk.utils.mapping_helpers import (
27+
combine_mappings,
28+
_validate_component_request_option_paths,
29+
)
2730

2831

2932
@dataclass
@@ -113,9 +116,9 @@ def __post_init__(self, parameters: Mapping[str, Any]) -> None:
113116
)
114117
if isinstance(self.url_base, str):
115118
self.url_base = InterpolatedString(string=self.url_base, parameters=parameters)
116-
119+
117120
if self.page_token_option and not isinstance(self.page_token_option, RequestPath):
118-
_validate_multiple_request_options(
121+
_validate_component_request_option_paths(
119122
self.config,
120123
self.page_size_option,
121124
self.page_token_option,

unit_tests/utils/test_mapping_helpers.py

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import 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
119124
def 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
)
157185
def 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
)
174219
def 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

Comments
 (0)