|
2 | 2 | # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
|
3 | 3 | #
|
4 | 4 |
|
| 5 | +from airbyte_cdk.test.state_builder import StateBuilder |
5 | 6 | from unit_tests.sources.file_based.helpers import LowHistoryLimitCursor
|
6 | 7 | from unit_tests.sources.file_based.scenarios.file_based_source_builder import FileBasedSourceBuilder
|
7 | 8 | from unit_tests.sources.file_based.scenarios.scenario_builder import IncrementalScenarioConfig, TestScenarioBuilder
|
|
39 | 40 | )
|
40 | 41 | .set_incremental_scenario_config(
|
41 | 42 | IncrementalScenarioConfig(
|
42 |
| - input_state=[ |
43 |
| - { |
44 |
| - "type": "STREAM", |
45 |
| - "stream": { |
46 |
| - "stream_state": { |
47 |
| - "history": {"some_old_file.csv": "2023-06-01T03:54:07.000000Z"}, |
48 |
| - }, |
49 |
| - "stream_descriptor": {"name": "stream1"}, |
50 |
| - }, |
51 |
| - } |
52 |
| - ], |
| 43 | + input_state=StateBuilder().with_stream_state("stream1", { |
| 44 | + "history": {"some_old_file.csv": "2023-06-01T03:54:07.000000Z"}, |
| 45 | + }).build(), |
53 | 46 | )
|
54 | 47 | )
|
55 | 48 | .set_expected_records(
|
|
140 | 133 | )
|
141 | 134 | .set_incremental_scenario_config(
|
142 | 135 | IncrementalScenarioConfig(
|
143 |
| - input_state=[ |
144 |
| - { |
145 |
| - "type": "STREAM", |
146 |
| - "stream": { |
147 |
| - "stream_state": { |
148 |
| - "history": {"a.csv": "2023-06-05T03:54:07.000000Z"}, |
149 |
| - }, |
150 |
| - "stream_descriptor": {"name": "stream1"}, |
151 |
| - }, |
152 |
| - } |
153 |
| - ], |
| 136 | + input_state=StateBuilder().with_stream_state("stream1", { |
| 137 | + "history": {"a.csv": "2023-06-05T03:54:07.000000Z"}, |
| 138 | + }).build(), |
154 | 139 | )
|
155 | 140 | )
|
156 | 141 | .set_expected_records(
|
|
223 | 208 | )
|
224 | 209 | .set_incremental_scenario_config(
|
225 | 210 | IncrementalScenarioConfig(
|
226 |
| - input_state=[ |
227 |
| - { |
228 |
| - "type": "STREAM", |
229 |
| - "stream": { |
230 |
| - "stream_state": { |
231 |
| - "history": {"a.csv": "2023-06-01T03:54:07.000000Z"}, |
232 |
| - }, |
233 |
| - "stream_descriptor": {"name": "stream1"}, |
234 |
| - }, |
235 |
| - } |
236 |
| - ], |
| 211 | + input_state=StateBuilder().with_stream_state("stream1", { |
| 212 | + "history": {"a.csv": "2023-06-01T03:54:07.000000Z"}, |
| 213 | + }).build(), |
237 | 214 | )
|
238 | 215 | )
|
239 | 216 | .set_expected_records(
|
|
377 | 354 | )
|
378 | 355 | .set_incremental_scenario_config(
|
379 | 356 | IncrementalScenarioConfig(
|
380 |
| - input_state=[], |
| 357 | + input_state=StateBuilder().build(), |
381 | 358 | )
|
382 | 359 | )
|
383 | 360 | ).build()
|
|
499 | 476 | )
|
500 | 477 | .set_incremental_scenario_config(
|
501 | 478 | IncrementalScenarioConfig(
|
502 |
| - input_state=[], |
| 479 | + input_state=StateBuilder().build(), |
503 | 480 | )
|
504 | 481 | )
|
505 | 482 | ).build()
|
|
593 | 570 | )
|
594 | 571 | .set_incremental_scenario_config(
|
595 | 572 | IncrementalScenarioConfig(
|
596 |
| - input_state=[ |
597 |
| - { |
598 |
| - "type": "STREAM", |
599 |
| - "stream": { |
600 |
| - "stream_state": {"history": {"recent_file.csv": "2023-07-15T23:59:59.000000Z"}}, |
601 |
| - "stream_descriptor": {"name": "stream1"}, |
602 |
| - }, |
603 |
| - } |
604 |
| - ], |
| 573 | + input_state=StateBuilder().with_stream_state("stream1", { |
| 574 | + "history": {"recent_file.csv": "2023-07-15T23:59:59.000000Z"}, |
| 575 | + }).build(), |
605 | 576 | )
|
606 | 577 | )
|
607 | 578 | ).build()
|
|
731 | 702 | )
|
732 | 703 | .set_incremental_scenario_config(
|
733 | 704 | IncrementalScenarioConfig(
|
734 |
| - input_state=[], |
| 705 | + input_state=StateBuilder().build(), |
735 | 706 | )
|
736 | 707 | )
|
737 | 708 | ).build()
|
|
891 | 862 | )
|
892 | 863 | .set_incremental_scenario_config(
|
893 | 864 | IncrementalScenarioConfig(
|
894 |
| - input_state=[], |
| 865 | + input_state=StateBuilder().build(), |
895 | 866 | )
|
896 | 867 | )
|
897 | 868 | ).build()
|
|
1035 | 1006 | )
|
1036 | 1007 | .set_incremental_scenario_config(
|
1037 | 1008 | IncrementalScenarioConfig(
|
1038 |
| - input_state=[ |
1039 |
| - { |
1040 |
| - "type": "STREAM", |
1041 |
| - "stream": { |
1042 |
| - "stream_state": {"history": {"a.csv": "2023-06-05T03:54:07.000000Z"}}, |
1043 |
| - "stream_descriptor": {"name": "stream1"}, |
1044 |
| - }, |
1045 |
| - } |
1046 |
| - ], |
| 1009 | + input_state=StateBuilder().with_stream_state("stream1", { |
| 1010 | + "history": {"a.csv": "2023-06-05T03:54:07.000000Z"}, |
| 1011 | + }).build(), |
1047 | 1012 | )
|
1048 | 1013 | )
|
1049 | 1014 | ).build()
|
|
1163 | 1128 | )
|
1164 | 1129 | .set_incremental_scenario_config(
|
1165 | 1130 | IncrementalScenarioConfig(
|
1166 |
| - input_state=[ |
1167 |
| - { |
1168 |
| - "type": "STREAM", |
1169 |
| - "stream": { |
1170 |
| - "stream_state": { |
1171 |
| - "history": {"a.csv": "2023-06-05T03:54:07.000000Z", "c.csv": "2023-06-06T03:54:07.000000Z"}, |
1172 |
| - }, |
1173 |
| - "stream_descriptor": {"name": "stream1"}, |
1174 |
| - }, |
1175 |
| - } |
1176 |
| - ], |
| 1131 | + input_state=StateBuilder().with_stream_state("stream1", { |
| 1132 | + "history": {"a.csv": "2023-06-05T03:54:07.000000Z", "c.csv": "2023-06-06T03:54:07.000000Z"}, |
| 1133 | + }).build(), |
1177 | 1134 | )
|
1178 | 1135 | )
|
1179 | 1136 | ).build()
|
|
1348 | 1305 | )
|
1349 | 1306 | .set_incremental_scenario_config(
|
1350 | 1307 | IncrementalScenarioConfig(
|
1351 |
| - input_state=[ |
1352 |
| - { |
1353 |
| - "type": "STREAM", |
1354 |
| - "stream": { |
1355 |
| - "stream_state": { |
1356 |
| - "history": { |
1357 |
| - "very_very_old_file.csv": "2023-06-01T03:54:07.000000Z", |
1358 |
| - "very_old_file.csv": "2023-06-02T03:54:07.000000Z", |
1359 |
| - "old_file_same_timestamp_as_a.csv": "2023-06-06T03:54:07.000000Z", |
1360 |
| - }, |
1361 |
| - }, |
1362 |
| - "stream_descriptor": {"name": "stream1"}, |
1363 |
| - }, |
1364 |
| - } |
1365 |
| - ], |
| 1308 | + input_state=StateBuilder().with_stream_state("stream1", { |
| 1309 | + "history": { |
| 1310 | + "very_very_old_file.csv": "2023-06-01T03:54:07.000000Z", |
| 1311 | + "very_old_file.csv": "2023-06-02T03:54:07.000000Z", |
| 1312 | + "old_file_same_timestamp_as_a.csv": "2023-06-06T03:54:07.000000Z", |
| 1313 | + }, |
| 1314 | + }).build(), |
1366 | 1315 | )
|
1367 | 1316 | )
|
1368 | 1317 | ).build()
|
|
1546 | 1495 | )
|
1547 | 1496 | .set_incremental_scenario_config(
|
1548 | 1497 | IncrementalScenarioConfig(
|
1549 |
| - input_state=[], |
| 1498 | + input_state=StateBuilder().build(), |
1550 | 1499 | )
|
1551 | 1500 | )
|
1552 | 1501 | ).build()
|
|
1652 | 1601 | )
|
1653 | 1602 | .set_incremental_scenario_config(
|
1654 | 1603 | IncrementalScenarioConfig(
|
1655 |
| - input_state=[ |
1656 |
| - { |
1657 |
| - "type": "STREAM", |
1658 |
| - "stream": { |
1659 |
| - "stream_state": { |
1660 |
| - "history": { |
1661 |
| - "b.csv": "2023-06-05T03:54:07.000000Z", |
1662 |
| - "c.csv": "2023-06-05T03:54:07.000000Z", |
1663 |
| - "d.csv": "2023-06-05T03:54:07.000000Z", |
1664 |
| - }, |
1665 |
| - }, |
1666 |
| - "stream_descriptor": {"name": "stream1"}, |
1667 |
| - }, |
1668 |
| - } |
1669 |
| - ], |
| 1604 | + input_state=StateBuilder().with_stream_state("stream1", { |
| 1605 | + "history": { |
| 1606 | + "b.csv": "2023-06-05T03:54:07.000000Z", |
| 1607 | + "c.csv": "2023-06-05T03:54:07.000000Z", |
| 1608 | + "d.csv": "2023-06-05T03:54:07.000000Z", |
| 1609 | + }, |
| 1610 | + }).build(), |
1670 | 1611 | )
|
1671 | 1612 | )
|
1672 | 1613 | ).build()
|
|
1794 | 1735 | )
|
1795 | 1736 | .set_incremental_scenario_config(
|
1796 | 1737 | IncrementalScenarioConfig(
|
1797 |
| - input_state=[ |
1798 |
| - { |
1799 |
| - "type": "STREAM", |
1800 |
| - "stream": { |
1801 |
| - "stream_state": { |
1802 |
| - "history": { |
1803 |
| - "c.csv": "2023-06-07T03:54:07.000000Z", |
1804 |
| - "d.csv": "2023-06-08T03:54:07.000000Z", |
1805 |
| - "e.csv": "2023-06-08T03:54:07.000000Z", |
1806 |
| - }, |
1807 |
| - }, |
1808 |
| - "stream_descriptor": {"name": "stream1"}, |
1809 |
| - }, |
1810 |
| - } |
1811 |
| - ], |
| 1738 | + input_state=StateBuilder().with_stream_state("stream1", { |
| 1739 | + "history": { |
| 1740 | + "c.csv": "2023-06-07T03:54:07.000000Z", |
| 1741 | + "d.csv": "2023-06-08T03:54:07.000000Z", |
| 1742 | + "e.csv": "2023-06-08T03:54:07.000000Z", |
| 1743 | + }, |
| 1744 | + }).build(), |
1812 | 1745 | )
|
1813 | 1746 | )
|
1814 | 1747 | ).build()
|
|
1962 | 1895 | )
|
1963 | 1896 | .set_incremental_scenario_config(
|
1964 | 1897 | IncrementalScenarioConfig(
|
1965 |
| - input_state=[ |
1966 |
| - { |
1967 |
| - "type": "STREAM", |
1968 |
| - "stream": { |
1969 |
| - "stream_state": { |
1970 |
| - "history": { |
1971 |
| - "old_file.csv": "2023-06-05T00:00:00.000000Z", |
1972 |
| - "c.csv": "2023-06-07T03:54:07.000000Z", |
1973 |
| - "d.csv": "2023-06-08T03:54:07.000000Z", |
1974 |
| - }, |
1975 |
| - }, |
1976 |
| - "stream_descriptor": {"name": "stream1"}, |
1977 |
| - }, |
1978 |
| - } |
1979 |
| - ], |
| 1898 | + input_state=StateBuilder().with_stream_state("stream1", { |
| 1899 | + "history": { |
| 1900 | + "old_file.csv": "2023-06-05T00:00:00.000000Z", |
| 1901 | + "c.csv": "2023-06-07T03:54:07.000000Z", |
| 1902 | + "d.csv": "2023-06-08T03:54:07.000000Z", |
| 1903 | + }, |
| 1904 | + }).build(), |
1980 | 1905 | )
|
1981 | 1906 | )
|
1982 | 1907 | ).build()
|
0 commit comments