Skip to content

Commit 141f77c

Browse files
Test first-application count after CSV reconciliation
1 parent ed920ab commit 141f77c

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

tests/test_wwpgd_projection_dose.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88

9-
from wwgpt.checkpointing import append_csv_records
9+
from wwgpt.checkpointing import append_csv_records, csv_commit, reconcile_csv_artifacts
1010

1111

1212
DOSE_DEFINITION = (
@@ -101,6 +101,23 @@ def test_layer_application_index_survives_sequential_appends(tmp_path):
101101
assert int(rows[2]["projection_event_number"]) == 3
102102

103103

104+
def test_reconciled_uncommitted_suffix_does_not_advance_application_count(tmp_path):
105+
path = tmp_path / "wwpgd_projection.csv"
106+
append_csv_records(path, [_projection_row(event=0, step=10, dose=0.05, changed=True)])
107+
committed = csv_commit(path)
108+
109+
# Simulate rows flushed after the last durable checkpoint, then a restart.
110+
append_csv_records(path, [_projection_row(event=1, step=20, dose=0.04, changed=True)])
111+
assert int(_read_rows(path)[-1]["layer_application_index"]) == 2
112+
reconcile_csv_artifacts(tmp_path, {path.name: committed})
113+
114+
append_csv_records(path, [_projection_row(event=2, step=30, dose=0.03, changed=True)])
115+
rows = _read_rows(path)
116+
assert len(rows) == 2
117+
assert int(rows[-1]["layer_application_index"]) == 2
118+
assert rows[-1]["is_first_applied_projection"] == "False"
119+
120+
104121
def test_first_application_is_tracked_independently_per_layer(tmp_path):
105122
path = tmp_path / "wwpgd_projection.csv"
106123
append_csv_records(

0 commit comments

Comments
 (0)