@@ -1047,8 +1047,19 @@ class TestTicketSubstream:
1047
1047
@pytest .mark .parametrize (
1048
1048
"stream_state, response, expected_slices" ,
1049
1049
[
1050
- ({}, {"tickets" : [{"id" : "13" }, {"id" : "80" }]}, [{"ticket_id" : "13" }, {"ticket_id" : "80" }]),
1051
- ({"updated_at" : "2024-04-17T19:34:06Z" }, {"tickets" : [{"id" : "80" }]}, [{"ticket_id" : "80" }]),
1050
+ (
1051
+ {},
1052
+ {"tickets" : [{"id" : "13" }, {"id" : "80" }]},
1053
+ [
1054
+ {"ticket_id" : "13" , "updated_at" : STREAM_ARGS ["start_date" ]},
1055
+ {"ticket_id" : "80" , "updated_at" : STREAM_ARGS ["start_date" ]},
1056
+ ],
1057
+ ),
1058
+ (
1059
+ {"updated_at" : "2024-04-17T19:34:06Z" },
1060
+ {"tickets" : [{"id" : "80" }]},
1061
+ [{"ticket_id" : "80" , "updated_at" : "2024-04-17T19:34:06Z" }],
1062
+ ),
1052
1063
({"updated_at" : "2224-04-17T19:34:06Z" }, {"tickets" : []}, []),
1053
1064
],
1054
1065
ids = [
@@ -1063,30 +1074,32 @@ def test_stream_slices(self, requests_mock, stream_state, response, expected_sli
1063
1074
assert list (stream .stream_slices (sync_mode = SyncMode .full_refresh , stream_state = stream_state )) == expected_slices
1064
1075
1065
1076
@pytest .mark .parametrize (
1066
- "stream_state , response, expected_records" ,
1077
+ "stream_slice , response, expected_records" ,
1067
1078
[
1068
- ({}, {"updated_at" : "2024-04-17T19:34:06Z" , "id" : "test id" }, [{"id" : "test id" , "updated_at" : "2024-04-17T19:34:06Z" }]),
1069
- ({}, {"updated_at" : "1979-04-17T19:34:06Z" , "id" : "test id" }, []),
1079
+ ({"updated_at" : "2024-05-17T19:34:06Z" }, {"updated_at" : "2024-04-17T19:34:06Z" , "id" : "test id" }, []),
1070
1080
(
1071
- {"updated_at" : "2024-04-17T19:34:06Z" },
1072
- {"updated_at" : "2024-04-18T19:34:06Z" , "id" : "test id" },
1073
- [{"updated_at" : "2024-04-18T19:34:06Z" , "id" : "test id" }],
1081
+ {"updated_at" : "2024-03-17T19:34:06Z" },
1082
+ {"updated_at" : "2024-04-17T19:34:06Z" , "id" : "test id" },
1083
+ [{"updated_at" : "2024-04-17T19:34:06Z" , "id" : "test id" }],
1084
+ ),
1085
+ (
1086
+ {},
1087
+ {"updated_at" : "1979-04-17T19:34:06Z" , "id" : "test id" },
1088
+ [{"updated_at" : "1979-04-17T19:34:06Z" , "id" : "test id" }],
1074
1089
),
1075
- ({"updated_at" : "2024-04-17T19:34:06Z" }, {"updated_at" : "1979-04-18T19:34:06Z" , "id" : "test id" }, []),
1076
1090
],
1077
1091
ids = [
1078
- "read_without_state" ,
1079
- "read_without_state_cursor_older_then_start_date" ,
1080
- "read_with_state" ,
1081
- "read_with_state_cursor_older_then_state_value" ,
1092
+ "read_with_slice_cursor_greater_than_record_cursor" ,
1093
+ "read_with_slice_cursor_less_than_record_cursor" ,
1094
+ "read_without_slice_cursor" ,
1082
1095
],
1083
1096
)
1084
- def test_ticket_metrics_parse_response (self , stream_state , response , expected_records ):
1097
+ def test_ticket_metrics_parse_response (self , stream_slice , response , expected_records ):
1085
1098
stream = get_stream_instance (TicketMetrics , STREAM_ARGS )
1086
1099
mocked_response = Mock ()
1087
- mocked_response .json .return_value = {"ticket_metric" : { "updated_at" : "2024-04-17T19:34:06Z" , "id" : "test id" } }
1088
- records = list (stream .parse_response (mocked_response , stream_state = stream_state ))
1089
- assert records == [{ "id" : "test id" , "updated_at" : "2024-04-17T19:34:06Z" }]
1100
+ mocked_response .json .return_value = {"ticket_metric" : response }
1101
+ records = list (stream .parse_response (mocked_response , stream_state = {}, stream_slice = stream_slice ))
1102
+ assert records == expected_records
1090
1103
1091
1104
def test_read_ticket_metrics_with_error (self , requests_mock ):
1092
1105
stream = get_stream_instance (TicketMetrics , STREAM_ARGS )
0 commit comments