Lazy clock reads; demo: auto-advancing +1h clock, module-level setup

This commit is contained in:
Leo Vasanko
2026-08-07 00:01:16 +00:00
parent 8d9e948d27
commit 5d66d423da
7 changed files with 98 additions and 88 deletions
+21
View File
@@ -72,6 +72,27 @@ async def test_clock_controls_record_timestamps(tmp_path, format_config):
assert kanta.mtime == T0 + timedelta(hours=1)
@pytest.mark.asyncio
async def test_clock_not_read_without_changes(tmp_path, format_config):
kanta = make_kanta(tmp_path / "test.db", Data, format_config)
reads = 0
@kanta.clock
def fake_now() -> datetime:
nonlocal reads
reads += 1
return T0
await kanta.open(log=False) # bootstrap record: one read
reads = 0
with kanta.transaction(action="noop"):
pass # no changes, no record, no clock read
await kanta.close() # no snapshot written, no clock read
assert reads == 0
@pytest.mark.asyncio
async def test_clock_controls_migration_and_snapshot_timestamps(
tmp_path, format_config