refactor: change backup_orders to use cutoff param instead of start/end
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -41,8 +41,7 @@ def test_backup_filters_by_state_and_date(tmp_path):
|
||||
result = backup_orders(
|
||||
scan_path=scan_csv,
|
||||
backup_dir=backup_dir,
|
||||
start=datetime(2025, 1, 1, tzinfo=timezone.utc),
|
||||
end=datetime(2025, 1, 3, tzinfo=timezone.utc),
|
||||
cutoff=datetime(2025, 1, 3, tzinfo=timezone.utc),
|
||||
)
|
||||
|
||||
assert result == 2
|
||||
@@ -56,3 +55,30 @@ def test_backup_filters_by_state_and_date(tmp_path):
|
||||
jan1_rows = list(read_csv(jan1))
|
||||
assert len(jan1_rows) == 1
|
||||
assert jan1_rows[0]["RowKey"] == "o1"
|
||||
|
||||
|
||||
def test_backup_filters_by_cutoff(tmp_path):
|
||||
scan_dir = tmp_path / "scan"
|
||||
backup_dir = tmp_path / "backups"
|
||||
scan_dir.mkdir()
|
||||
backup_dir.mkdir()
|
||||
|
||||
entities = [
|
||||
_make_entity("u1", "o1", datetime(2025, 1, 1, 10, tzinfo=timezone.utc), 1),
|
||||
_make_entity("u2", "o2", datetime(2025, 1, 2, 8, tzinfo=timezone.utc), 1),
|
||||
_make_entity("u3", "o3", datetime(2025, 1, 3, 8, tzinfo=timezone.utc), 1), # at/after cutoff
|
||||
]
|
||||
scan_csv = scan_dir / "scan-2025-01-03.csv"
|
||||
write_csv(scan_csv, entities)
|
||||
|
||||
cutoff = datetime(2025, 1, 3, tzinfo=timezone.utc)
|
||||
result = backup_orders(
|
||||
scan_path=scan_csv,
|
||||
backup_dir=backup_dir,
|
||||
cutoff=cutoff,
|
||||
)
|
||||
|
||||
assert result == 2
|
||||
assert (backup_dir / "2025-01-01.csv").exists()
|
||||
assert (backup_dir / "2025-01-02.csv").exists()
|
||||
assert not (backup_dir / "2025-01-03.csv").exists()
|
||||
|
||||
Reference in New Issue
Block a user