|
20 | 20 | ConcurrentDeclarativeSource,
|
21 | 21 | )
|
22 | 22 | from airbyte_cdk.sources.declarative.incremental import ConcurrentPerPartitionCursor
|
| 23 | +from airbyte_cdk.sources.declarative.partition_routers import ListPartitionRouter |
23 | 24 | from airbyte_cdk.sources.declarative.schema import InlineSchemaLoader
|
24 | 25 | from airbyte_cdk.sources.declarative.stream_slicers.declarative_partition_generator import (
|
25 | 26 | DeclarativePartition,
|
|
29 | 30 | from airbyte_cdk.sources.streams.concurrent.state_converters.datetime_stream_state_converter import (
|
30 | 31 | CustomFormatConcurrentStreamStateConverter,
|
31 | 32 | )
|
32 |
| -from airbyte_cdk.sources.types import StreamSlice |
| 33 | +from airbyte_cdk.sources.types import Record, StreamSlice |
33 | 34 | from airbyte_cdk.test.catalog_builder import CatalogBuilder, ConfiguredAirbyteStreamBuilder
|
34 | 35 | from airbyte_cdk.test.entrypoint_wrapper import EntrypointOutput, read
|
35 | 36 |
|
@@ -4400,3 +4401,34 @@ def test_duplicate_partition_while_processing():
|
4400 | 4401 | assert len(cursor._processing_partitions_indexes) == 0
|
4401 | 4402 | assert len(cursor._partition_key_to_index) == 0
|
4402 | 4403 | assert len(cursor._partitions_done_generating_stream_slices) == 0
|
| 4404 | + |
| 4405 | + |
| 4406 | +def test_given_record_with_bad_cursor_value_the_global_state_parsing_does_not_break_sync(): |
| 4407 | + cursor_factory_mock = MagicMock() |
| 4408 | + cursor_factory_mock.create.side_effect = [_make_inner_cursor("2024-01-01T00:00:00Z")] |
| 4409 | + cursor = ConcurrentPerPartitionCursor( |
| 4410 | + cursor_factory=MagicMock(), |
| 4411 | + partition_router=ListPartitionRouter( |
| 4412 | + values=["1"], cursor_field="partition_id", config={}, parameters={} |
| 4413 | + ), |
| 4414 | + stream_name="test_stream", |
| 4415 | + stream_namespace=None, |
| 4416 | + stream_state={}, |
| 4417 | + message_repository=MagicMock(), |
| 4418 | + connector_state_manager=MagicMock(), |
| 4419 | + connector_state_converter=CustomFormatConcurrentStreamStateConverter( |
| 4420 | + datetime_format="%Y-%m-%dT%H:%M:%SZ", |
| 4421 | + input_datetime_formats=["%Y-%m-%dT%H:%M:%SZ"], |
| 4422 | + is_sequential_state=True, |
| 4423 | + cursor_granularity=timedelta(0), |
| 4424 | + ), |
| 4425 | + cursor_field=CursorField(cursor_field_key="updated_at"), |
| 4426 | + ) |
| 4427 | + |
| 4428 | + cursor.observe( |
| 4429 | + Record( |
| 4430 | + data={"updated_at": ""}, |
| 4431 | + stream_name="test_stream", |
| 4432 | + associated_slice=StreamSlice(partition={"partition_id": "1"}, cursor_slice={}), |
| 4433 | + ) |
| 4434 | + ) |
0 commit comments