Review
Freeze BrineSlot harvest-hold expiry under freezegun
BrineSlot books low-tide oyster harvest windows for Puget Sound DNR leases. Adds a freezegun regression test so the 60-minute landing-hold expiry label stays pinned when we change hold issuance — CI kept drifting after the last schedule rewrite.
pytestTier 3pytestfreezeguntimezoneflaky
Click a line to flag it, pick one or more labels, then submit. If the change looks correct, approve it.
tests/test_harvest_hold_expiry.py+17-0
| 1 | + | from datetime import datetime, timedelta | |
| 2 | + | ||
| 3 | + | from freezegun import freeze_time | |
| 4 | + | ||
| 5 | + | from brineslot.holds import issue_harvest_hold | |
| 6 | + | ||
| 7 | + | ||
| 8 | + | @freeze_time("2024-08-15 14:00:00") | |
| 9 | + | def test_harvest_hold_expires_one_hour_after_issue(): | |
| 10 | + | """Hold must lapse 60m after issue; label is harbor wall clock.""" | |
| 11 | + | hold = issue_harvest_hold(lease_id="PS-441", bed="Hood Canal 7") | |
| 12 | + | # production: datetime.now(ZoneInfo("America/Los_Angeles")) + 1h | |
| 13 | + | assert hold.expires_at.hour == 15 | |
| 14 | + | assert hold.expires_display == "3:00 PM PDT" | |
| 15 | + | # sanity: still within the afternoon low-tide window | |
| 16 | + | assert datetime.now().strftime("%H:%M") == "14:00" | |
| 17 | + | assert hold.expires_at - datetime.now() == timedelta(hours=1) |