Skip to content

Commit ad75c52

Browse files
committed
Merge branch 'lazebnyi/add-lazy-read-to-simple-retriver' of github.com:airbytehq/airbyte-python-cdk into lazebnyi/add-lazy-read-to-simple-retriver
2 parents f19d048 + 4f03269 commit ad75c52

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

unit_tests/sources/declarative/retrievers/test_lazy_simple_retriever.py

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@
6464
"page_token_option": {
6565
"type": "RequestOption",
6666
"inject_into": "request_parameter",
67-
"field_name": "starting_after"
67+
"field_name": "starting_after",
6868
},
6969
"pagination_strategy": {
7070
"type": "CursorPagination",
7171
"cursor_value": '{{ response["data"][-1]["id"] }}',
72-
"stop_condition": '{{ not response.get("has_more", False) }}'
73-
}
72+
"stop_condition": '{{ not response.get("has_more", False) }}',
73+
},
7474
},
7575
"partition_router": {
7676
"type": "SubstreamPartitionRouter",
@@ -218,37 +218,37 @@ def test_retriever_with_lazy_reading():
218218
body=json.dumps(
219219
{
220220
"data": [
221-
{"id": 1, "name": "parent_1", "updated_at": "2024-07-13", "items": {"data": [{"id": 1}, {"id": 2}], "has_more": True}},
222-
{"id": 2, "name": "parent_2", "updated_at": "2024-07-13", "items": {"data": [{"id": 3}, {"id": 4}], "has_more": False}},
221+
{
222+
"id": 1,
223+
"name": "parent_1",
224+
"updated_at": "2024-07-13",
225+
"items": {"data": [{"id": 1}, {"id": 2}], "has_more": True},
226+
},
227+
{
228+
"id": 2,
229+
"name": "parent_2",
230+
"updated_at": "2024-07-13",
231+
"items": {"data": [{"id": 3}, {"id": 4}], "has_more": False},
232+
},
223233
],
224-
"has_more": False
234+
"has_more": False,
225235
}
226236
)
227237
),
228238
)
229239

230240
http_mocker.get(
231-
HttpRequest(url="https://api.test.com/parent/1/items?starting_after=2&start=2024-07-01&end=2024-07-15"),
232-
HttpResponse(
233-
body=json.dumps(
234-
{
235-
"data": [{"id": 5}, {"id": 6}],
236-
"has_more": True
237-
}
238-
)
241+
HttpRequest(
242+
url="https://api.test.com/parent/1/items?starting_after=2&start=2024-07-01&end=2024-07-15"
239243
),
244+
HttpResponse(body=json.dumps({"data": [{"id": 5}, {"id": 6}], "has_more": True})),
240245
)
241246

242247
http_mocker.get(
243-
HttpRequest(url="https://api.test.com/parent/1/items?starting_after=6&start=2024-07-01&end=2024-07-15"),
244-
HttpResponse(
245-
body=json.dumps(
246-
{
247-
"data": [{"id": 7}],
248-
"has_more": False
249-
}
250-
)
248+
HttpRequest(
249+
url="https://api.test.com/parent/1/items?starting_after=6&start=2024-07-01&end=2024-07-15"
251250
),
251+
HttpResponse(body=json.dumps({"data": [{"id": 7}], "has_more": False})),
252252
)
253253

254254
source = ConcurrentDeclarativeSource(
@@ -280,12 +280,20 @@ def test_incremental_sync_with_state():
280280
body=json.dumps(
281281
{
282282
"data": [
283-
{"id": 1, "name": "parent_1", "updated_at": "2024-07-13",
284-
"items": {"data": [{"id": 1}, {"id": 2}], "has_more": False}},
285-
{"id": 2, "name": "parent_2", "updated_at": "2024-07-13",
286-
"items": {"data": [{"id": 3}, {"id": 4}], "has_more": False}},
283+
{
284+
"id": 1,
285+
"name": "parent_1",
286+
"updated_at": "2024-07-13",
287+
"items": {"data": [{"id": 1}, {"id": 2}], "has_more": False},
288+
},
289+
{
290+
"id": 2,
291+
"name": "parent_2",
292+
"updated_at": "2024-07-13",
293+
"items": {"data": [{"id": 3}, {"id": 4}], "has_more": False},
294+
},
287295
],
288-
"has_more": False
296+
"has_more": False,
289297
}
290298
)
291299
),
@@ -295,21 +303,15 @@ def test_incremental_sync_with_state():
295303
HttpRequest(url="https://api.test.com/parent/1/items?start=2024-07-13&end=2024-07-15"),
296304
HttpResponse(
297305
body=json.dumps(
298-
{
299-
"data": [{"id": 10, "updated_at": "2024-07-13"}],
300-
"has_more": False
301-
}
306+
{"data": [{"id": 10, "updated_at": "2024-07-13"}], "has_more": False}
302307
)
303308
),
304309
)
305310
http_mocker.get(
306311
HttpRequest(url="https://api.test.com/parent/2/items?start=2024-07-13&end=2024-07-15"),
307312
HttpResponse(
308313
body=json.dumps(
309-
{
310-
"data": [{"id": 11, "updated_at": "2024-07-13"}],
311-
"has_more": False
312-
}
314+
{"data": [{"id": 11, "updated_at": "2024-07-13"}], "has_more": False}
313315
)
314316
),
315317
)
@@ -335,4 +337,3 @@ def test_incremental_sync_with_state():
335337
{"id": 11, "updated_at": "2024-07-13"},
336338
]
337339
assert expected_incremental == incremental_records
338-

0 commit comments

Comments
 (0)