Skip to content

Commit 1a57ba8

Browse files
author
maxi297
committed
adding test
1 parent 7d0c069 commit 1a57ba8

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

unit_tests/sources/declarative/incremental/test_concurrent_perpartitioncursor.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3449,3 +3449,43 @@ def test_semaphore_cleanup():
34493449
assert '{"id":"2"}' not in cursor._semaphore_per_partition
34503450
assert len(cursor._partition_parent_state_map) == 0 # All parent states should be popped
34513451
assert cursor._parent_state == {"parent": {"state": "state2"}} # Last parent state
3452+
3453+
3454+
def test_given_global_state_when_read_then_state_is_not_per_partition() -> None:
3455+
manifest = deepcopy(SUBSTREAM_MANIFEST)
3456+
manifest["definitions"]["post_comments_stream"]["incremental_sync"]["global_substream_cursor"] = True
3457+
record = {
3458+
"id": 9,
3459+
"post_id": 1,
3460+
"updated_at": COMMENT_10_UPDATED_AT,
3461+
}
3462+
mock_requests = [
3463+
(
3464+
f"https://api.example.com/community/posts?per_page=100&start_time={START_DATE}",
3465+
{
3466+
"posts": [
3467+
{"id": 1, "updated_at": POST_1_UPDATED_AT},
3468+
],
3469+
},
3470+
),
3471+
# Fetch the first page of comments for post 1
3472+
(
3473+
"https://api.example.com/community/posts/1/comments?per_page=100",
3474+
{
3475+
"comments": [record],
3476+
},
3477+
),
3478+
]
3479+
run_mocked_test(
3480+
mock_requests,
3481+
manifest,
3482+
CONFIG,
3483+
"post_comments",
3484+
{},
3485+
[record],
3486+
{
3487+
"lookback_window": 1,
3488+
"parent_state": {"posts": {"updated_at": "2024-01-30T00:00:00Z"}},
3489+
"state": {"updated_at": "2024-01-25T00:00:00Z"}
3490+
}, # this state does have per partition which would be under `states`
3491+
)

0 commit comments

Comments
 (0)