Skip to content

Commit ad730cf

Browse files
committed
fix typing and add tests
1 parent cd1dc82 commit ad730cf

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

airbyte_cdk/sources/declarative/requesters/query_properties/property_chunking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __post_init__(self, parameters: Mapping[str, Any]) -> None:
4040
)
4141

4242
def get_request_property_chunks(
43-
self, property_fields: Iterable[str], always_include_properties: Optional[List[str]]
43+
self, property_fields: List[str], always_include_properties: Optional[List[str]]
4444
) -> Iterable[List[str]]:
4545
if not self.property_limit:
4646
single_property_chunk = list(property_fields)

airbyte_cdk/sources/declarative/requesters/query_properties/query_properties.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_request_property_chunks(
3434
:param stream_slice: The StreamSlice of the current partition being processed during the sync. This is included
3535
because subcomponents of QueryProperties can make use of interpolation of the top-level StreamSlice object
3636
"""
37-
fields: Union[Iterable[str], List[str]]
37+
fields: List[str]
3838
if isinstance(self.property_list, PropertiesFromEndpoint):
3939
fields = self.property_list.get_properties_from_endpoint(stream_slice=stream_slice)
4040
else:

unit_tests/sources/declarative/requesters/query_properties/test_property_chunking.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ def test_get_request_property_chunks(
7272
property_limit,
7373
expected_property_chunks,
7474
):
75-
property_fields = iter(property_fields)
7675
property_chunking = PropertyChunking(
7776
property_limit_type=property_limit_type,
7877
property_limit=property_limit,
@@ -104,3 +103,26 @@ def test_get_merge_key():
104103

105104
merge_key = property_chunking.get_merge_key(record=record)
106105
assert merge_key == "0"
106+
107+
108+
def test_given_single_property_chunk_when_get_request_property_chunks_then_always_include_properties_are_not_added_to_input_list():
109+
"""
110+
This test is used to validate that we don't manipulate the in-memory values from get_request_property_chunks
111+
"""
112+
property_chunking = PropertyChunking(
113+
property_limit_type=PropertyLimitType.property_count,
114+
property_limit=None,
115+
record_merge_strategy=GroupByKey(key="id", config=CONFIG, parameters={}),
116+
config=CONFIG,
117+
parameters={},
118+
)
119+
120+
property_fields = ["rick", "chelsea", "victoria", "tim", "saxon", "lochlan", "piper"]
121+
list(
122+
property_chunking.get_request_property_chunks(
123+
property_fields=property_fields,
124+
always_include_properties=["id"],
125+
)
126+
)
127+
128+
assert property_fields == ["rick", "chelsea", "victoria", "tim", "saxon", "lochlan", "piper"]

0 commit comments

Comments
 (0)