6565 },
6666 "cursor_incremental_sync" : {
6767 "type" : "DatetimeBasedCursor" ,
68- "cursor_datetime_formats" : ["%Y-%m-%dT%H:%M:%SZ" , "%Y-%m-%dT%H:%M:%S%z" ],
68+ "cursor_datetime_formats" : ["%Y-%m-%dT%H:%M:%SZ" , "%Y-%m-%dT%H:%M:%S%z" , "%ms" ],
6969 "datetime_format" : "%Y-%m-%dT%H:%M:%SZ" ,
7070 "cursor_field" : "{{ parameters.get('cursor_field', 'updated_at') }}" ,
7171 "start_datetime" : {"datetime" : "{{ config.get('start_date')}}" },
@@ -399,13 +399,16 @@ def _run_read(
399399VOTE_200_CREATED_AT = "2024-01-12T00:00:00Z" # Latest vote in partition 20
400400VOTE_210_CREATED_AT = "2024-01-12T00:00:15Z" # Latest vote in partition 21
401401VOTE_300_CREATED_AT = "2024-01-10T00:00:00Z" # Latest vote in partition 30
402+ VOTE_300_CREATED_AT_TIMESTAMP = 1704844800000 # Latest vote in partition 30
402403
403404# Initial State Constants
404405PARENT_COMMENT_CURSOR_PARTITION_1 = "2023-01-04T00:00:00Z" # Parent comment cursor (partition)
405406PARENT_POSTS_CURSOR = "2024-01-05T00:00:00Z" # Parent posts cursor (expected in state)
406407
407408INITIAL_STATE_PARTITION_10_CURSOR = "2024-01-02T00:00:01Z"
409+ INITIAL_STATE_PARTITION_10_CURSOR_TIMESTAMP = 1704153601000
408410INITIAL_STATE_PARTITION_11_CURSOR = "2024-01-03T00:00:02Z"
411+ INITIAL_STATE_PARTITION_11_CURSOR_TIMESTAMP = 1704240002000
409412INITIAL_GLOBAL_CURSOR = INITIAL_STATE_PARTITION_11_CURSOR
410413INITIAL_GLOBAL_CURSOR_DATE = datetime .fromisoformat (
411414 INITIAL_STATE_PARTITION_11_CURSOR .replace ("Z" , "" )
@@ -596,7 +599,7 @@ def _run_read(
596599 {
597600 "id" : 300 ,
598601 "comment_id" : 30 ,
599- "created_at" : VOTE_300_CREATED_AT ,
602+ "created_at" : VOTE_300_CREATED_AT_TIMESTAMP ,
600603 }
601604 ]
602605 },
@@ -637,7 +640,7 @@ def _run_read(
637640 {
638641 "comment_id" : 30 ,
639642 "comment_updated_at" : COMMENT_30_UPDATED_AT ,
640- "created_at" : VOTE_300_CREATED_AT ,
643+ "created_at" : str ( VOTE_300_CREATED_AT_TIMESTAMP ) ,
641644 "id" : 300 ,
642645 },
643646 ],
@@ -662,7 +665,7 @@ def _run_read(
662665 "id" : 10 ,
663666 "parent_slice" : {"id" : 1 , "parent_slice" : {}},
664667 },
665- "cursor" : {"created_at" : INITIAL_STATE_PARTITION_10_CURSOR },
668+ "cursor" : {"created_at" : INITIAL_STATE_PARTITION_10_CURSOR_TIMESTAMP },
666669 },
667670 {
668671 "partition" : {
@@ -672,7 +675,7 @@ def _run_read(
672675 "cursor" : {"created_at" : INITIAL_STATE_PARTITION_11_CURSOR },
673676 },
674677 ],
675- "state" : {"created_at" : INITIAL_STATE_PARTITION_11_CURSOR },
678+ "state" : {"created_at" : INITIAL_STATE_PARTITION_11_CURSOR_TIMESTAMP },
676679 "lookback_window" : 86400 ,
677680 },
678681 # Expected state
@@ -981,7 +984,15 @@ def run_incremental_parent_state_test(
981984 # Fetch the first page of votes for comment 30 of post 3
982985 (
983986 f"https://api.example.com/community/posts/3/comments/30/votes?per_page=100&start_time={ LOOKBACK_DATE } " ,
984- {"votes" : [{"id" : 300 , "comment_id" : 30 , "created_at" : VOTE_300_CREATED_AT }]},
987+ {
988+ "votes" : [
989+ {
990+ "id" : 300 ,
991+ "comment_id" : 30 ,
992+ "created_at" : VOTE_300_CREATED_AT_TIMESTAMP ,
993+ }
994+ ]
995+ },
985996 ),
986997 # Requests with intermediate states
987998 # Fetch votes for comment 10 of post 1
@@ -1018,7 +1029,15 @@ def run_incremental_parent_state_test(
10181029 # Fetch votes for comment 30 of post 3
10191030 (
10201031 f"https://api.example.com/community/posts/3/comments/30/votes?per_page=100&start_time={ VOTE_300_CREATED_AT } " ,
1021- {"votes" : [{"id" : 300 , "comment_id" : 30 , "created_at" : VOTE_300_CREATED_AT }]},
1032+ {
1033+ "votes" : [
1034+ {
1035+ "id" : 300 ,
1036+ "comment_id" : 30 ,
1037+ "created_at" : VOTE_300_CREATED_AT_TIMESTAMP ,
1038+ }
1039+ ]
1040+ },
10221041 ),
10231042 ],
10241043 # Expected records
@@ -1056,7 +1075,7 @@ def run_incremental_parent_state_test(
10561075 {
10571076 "comment_id" : 30 ,
10581077 "comment_updated_at" : COMMENT_30_UPDATED_AT ,
1059- "created_at" : VOTE_300_CREATED_AT ,
1078+ "created_at" : str ( VOTE_300_CREATED_AT_TIMESTAMP ) ,
10601079 "id" : 300 ,
10611080 },
10621081 ],
@@ -1344,7 +1363,15 @@ def test_incremental_parent_state(
13441363 (
13451364 f"https://api.example.com/community/posts/3/comments/30/votes"
13461365 f"?per_page=100&start_time={ PARTITION_SYNC_START_TIME } " ,
1347- {"votes" : [{"id" : 300 , "comment_id" : 30 , "created_at" : VOTE_300_CREATED_AT }]},
1366+ {
1367+ "votes" : [
1368+ {
1369+ "id" : 300 ,
1370+ "comment_id" : 30 ,
1371+ "created_at" : VOTE_300_CREATED_AT_TIMESTAMP ,
1372+ }
1373+ ]
1374+ },
13481375 ),
13491376 ],
13501377 # Expected records
@@ -1382,7 +1409,7 @@ def test_incremental_parent_state(
13821409 {
13831410 "comment_id" : 30 ,
13841411 "comment_updated_at" : COMMENT_30_UPDATED_AT ,
1385- "created_at" : VOTE_300_CREATED_AT ,
1412+ "created_at" : str ( VOTE_300_CREATED_AT_TIMESTAMP ) ,
13861413 "id" : 300 ,
13871414 },
13881415 ],
@@ -1896,7 +1923,15 @@ def test_incremental_parent_state_no_records(
18961923 (
18971924 f"https://api.example.com/community/posts/3/comments/30/votes"
18981925 f"?per_page=100&start_time={ LOOKBACK_DATE } " ,
1899- {"votes" : [{"id" : 300 , "comment_id" : 30 , "created_at" : VOTE_300_CREATED_AT }]},
1926+ {
1927+ "votes" : [
1928+ {
1929+ "id" : 300 ,
1930+ "comment_id" : 30 ,
1931+ "created_at" : VOTE_300_CREATED_AT_TIMESTAMP ,
1932+ }
1933+ ]
1934+ },
19001935 ),
19011936 ],
19021937 # Expected records
@@ -1928,7 +1963,7 @@ def test_incremental_parent_state_no_records(
19281963 {
19291964 "comment_id" : 30 ,
19301965 "comment_updated_at" : COMMENT_30_UPDATED_AT ,
1931- "created_at" : VOTE_300_CREATED_AT ,
1966+ "created_at" : str ( VOTE_300_CREATED_AT_TIMESTAMP ) ,
19321967 "id" : 300 ,
19331968 },
19341969 ],
0 commit comments