From cc5075ba53b23d74b8ad74ad195e7f11c6146360 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Fri, 21 Aug 2026 13:43:34 +0200 Subject: [PATCH] Cover _tombstoned_ids Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_018M5gKyYzxWG6QkCaj1wWfk --- screen_locker/tests/test_workout_sync.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/screen_locker/tests/test_workout_sync.py b/screen_locker/tests/test_workout_sync.py index 1eb7abd..dac7b15 100644 --- a/screen_locker/tests/test_workout_sync.py +++ b/screen_locker/tests/test_workout_sync.py @@ -12,7 +12,7 @@ import json from crdt_sync import Hlc, Record import pytest -from screen_locker import _workout_sync +from screen_locker import _sync_records, _workout_sync from screen_locker.tests._workout_sync_fixtures import ( _manual_payload, _manual_record_dict, @@ -155,3 +155,25 @@ class TestManualRecords: """Raises type error when top level is not an object.""" with pytest.raises(TypeError, match="not a JSON object"): _workout_sync._manual_records(json.dumps([1, 2, 3])) + + +class TestTombstonedIds: + """TombstonedIds.""" + + def test_returns_only_the_deleted_ids(self) -> None: + """Returns only the deleted ids.""" + hlc = Hlc(wall_time_ms=1, counter=0, node_id="phone") + live = Record(id="live", fields={"payload": ({"a": 1}, hlc)}) + gone = Record( + id="gone", + fields={"payload": ({"a": 1}, hlc)}, + deleted=True, + deleted_hlc=hlc, + ) + log = {"x": live.to_dict(), "y": gone.to_dict()} + assert _sync_records._tombstoned_ids(json.dumps(log)) == {"gone"} + + def test_raises_type_error_when_top_level_is_not_an_object(self) -> None: + """Raises type error when top level is not an object.""" + with pytest.raises(TypeError, match="not a JSON object"): + _sync_records._tombstoned_ids(json.dumps([1, 2, 3]))