Lazy clock reads; demo: auto-advancing +1h clock, module-level setup
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user