From 006bc755275b4753b51c580538bb6da4c3bf088f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Mon, 22 Jan 2024 17:12:20 -0600 Subject: [PATCH] Add test --- singer_sdk/helpers/_state.py | 2 +- tests/core/test_state_handling.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/singer_sdk/helpers/_state.py b/singer_sdk/helpers/_state.py index 8faab5a7e..e265be97b 100644 --- a/singer_sdk/helpers/_state.py +++ b/singer_sdk/helpers/_state.py @@ -214,7 +214,7 @@ def increment_state( "Stream is assumed to be unsorted, progress is not resumable if " "interrupted", extra={"replication_key": replication_key}, - ) # pragma: no cover + ) progress_dict = stream_or_partition_state[PROGRESS_MARKERS] old_rk_value = to_json_compatible(progress_dict.get("replication_key_value")) new_rk_value = to_json_compatible(latest_record[replication_key]) diff --git a/tests/core/test_state_handling.py b/tests/core/test_state_handling.py index 339df1f4c..3f4fff148 100644 --- a/tests/core/test_state_handling.py +++ b/tests/core/test_state_handling.py @@ -103,3 +103,27 @@ def test_state_finalize(dirty_state, finalized_state): for partition_state in stream_state.get("partitions", []): _state.finalize_state_progress_markers(partition_state) assert state == finalized_state + + +def test_irresumable_state(): + stream_state = {} + latest_record = {"updated_at": "2021-05-17T20:41:16Z"} + replication_key = "updated_at" + is_sorted = False + check_sorted = False + + _state.increment_state( + stream_state, + latest_record=latest_record, + replication_key=replication_key, + is_sorted=is_sorted, + check_sorted=check_sorted, + ) + + assert stream_state == { + "progress_markers": { + "Note": "Progress is not resumable if interrupted.", + "replication_key": "updated_at", + "replication_key_value": "2021-05-17T20:41:16Z", + }, + }