Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Jan 22, 2024
1 parent fcc6c52 commit 006bc75
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion singer_sdk/helpers/_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
24 changes: 24 additions & 0 deletions tests/core/test_state_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}

0 comments on commit 006bc75

Please sign in to comment.