Skip to content

Commit 8dee91a

Browse files
committed
Initial batch of fixes
1 parent 43bf6be commit 8dee91a

File tree

2 files changed

+28
-61
lines changed

2 files changed

+28
-61
lines changed

pgcommitfest/commitfest/models.py

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -154,40 +154,25 @@ def auto_move_active_patches(self):
154154
"""
155155
current_date = datetime.now()
156156

157-
# Get the next open commitfest
157+
# Get the next open commitfest (must exist, raises IndexError otherwise)
158158
# For draft CFs, find the next draft CF
159159
# For regular CFs, find the next regular CF by start date
160160
if self.draft:
161-
next_cf = (
162-
CommitFest.objects.filter(
163-
status=CommitFest.STATUS_OPEN,
164-
draft=True,
165-
startdate__gt=self.enddate,
166-
)
167-
.order_by("startdate")
168-
.first()
169-
)
161+
next_cf = CommitFest.objects.filter(
162+
status=CommitFest.STATUS_OPEN,
163+
draft=True,
164+
startdate__gt=self.enddate,
165+
).order_by("startdate")[0]
170166
else:
171-
next_cf = (
172-
CommitFest.objects.filter(
173-
status=CommitFest.STATUS_OPEN,
174-
draft=False,
175-
startdate__gt=self.enddate,
176-
)
177-
.order_by("startdate")
178-
.first()
179-
)
180-
181-
if not next_cf:
182-
return set()
167+
next_cf = CommitFest.objects.filter(
168+
status=CommitFest.STATUS_OPEN,
169+
draft=False,
170+
startdate__gt=self.enddate,
171+
).order_by("startdate")[0]
183172

184173
# Get all patches with open status in this commitfest
185174
open_pocs = self.patchoncommitfest_set.filter(
186-
status__in=[
187-
PatchOnCommitFest.STATUS_REVIEW,
188-
PatchOnCommitFest.STATUS_AUTHOR,
189-
PatchOnCommitFest.STATUS_COMMITTER,
190-
]
175+
status__in=PatchOnCommitFest.OPEN_STATUSES
191176
).select_related("patch")
192177

193178
moved_patch_ids = set()
@@ -211,11 +196,7 @@ def send_closure_notifications(self, moved_patch_ids=None):
211196
# Get patches that still need action (not moved, not closed)
212197
open_pocs = list(
213198
self.patchoncommitfest_set.filter(
214-
status__in=[
215-
PatchOnCommitFest.STATUS_REVIEW,
216-
PatchOnCommitFest.STATUS_AUTHOR,
217-
PatchOnCommitFest.STATUS_COMMITTER,
218-
]
199+
status__in=PatchOnCommitFest.OPEN_STATUSES
219200
)
220201
.exclude(patch_id__in=moved_patch_ids)
221202
.select_related("patch")

pgcommitfest/commitfest/tests/test_closure_notifications.py

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -384,29 +384,6 @@ def test_auto_move_when_failing_within_threshold(alice, in_progress_cf, open_cf,
384384
assert QueuedMail.objects.count() == 0
385385

386386

387-
def test_no_auto_move_without_next_commitfest(alice, in_progress_cf, topic):
388-
"""Patches should not be auto-moved if there's no next commitfest."""
389-
patch = Patch.objects.create(
390-
name="Active Patch No Next CF",
391-
topic=topic,
392-
lastmail=datetime.now() - timedelta(days=5),
393-
)
394-
patch.authors.add(alice)
395-
PatchOnCommitFest.objects.create(
396-
patch=patch,
397-
commitfest=in_progress_cf,
398-
enterdate=datetime.now(),
399-
status=PatchOnCommitFest.STATUS_REVIEW,
400-
)
401-
402-
moved_patch_ids = in_progress_cf.auto_move_active_patches()
403-
in_progress_cf.send_closure_notifications(moved_patch_ids)
404-
405-
# Patch should NOT be moved (no next CF)
406-
patch.refresh_from_db()
407-
assert patch.current_commitfest().id == in_progress_cf.id
408-
409-
410387
def test_no_auto_move_with_null_lastmail(alice, in_progress_cf, open_cf, topic):
411388
"""Patches with no email activity (null lastmail) should NOT be auto-moved."""
412389
patch = Patch.objects.create(
@@ -458,15 +435,23 @@ def test_auto_move_patch_without_cfbot_branch(alice, in_progress_cf, open_cf, to
458435

459436

460437
def test_regular_cf_does_not_move_to_draft_cf(alice, in_progress_cf, topic):
461-
"""Regular commitfest should not move patches to a draft commitfest."""
462-
# Create only a draft CF as the "next" option (should be ignored)
463-
CommitFest.objects.create(
438+
"""Regular commitfest should move patches to the next regular CF, not a draft CF."""
439+
# Create a draft CF - should be ignored for regular CF patches
440+
draft_cf = CommitFest.objects.create(
464441
name="2025-05-draft",
465442
status=CommitFest.STATUS_OPEN,
466443
startdate=date(2025, 5, 1),
467444
enddate=date(2025, 5, 31),
468445
draft=True,
469446
)
447+
# Create a regular CF - this is where patches should go
448+
regular_cf = CommitFest.objects.create(
449+
name="2025-01",
450+
status=CommitFest.STATUS_OPEN,
451+
startdate=date(2025, 1, 1),
452+
enddate=date(2025, 1, 31),
453+
draft=False,
454+
)
470455

471456
patch = Patch.objects.create(
472457
name="Regular Patch",
@@ -483,10 +468,11 @@ def test_regular_cf_does_not_move_to_draft_cf(alice, in_progress_cf, topic):
483468

484469
moved_patch_ids = in_progress_cf.auto_move_active_patches()
485470

486-
# Should not be moved since only draft CF is available
487-
assert patch.id not in moved_patch_ids
471+
# Should be moved to regular CF, not draft CF
472+
assert patch.id in moved_patch_ids
488473
patch.refresh_from_db()
489-
assert patch.current_commitfest().id == in_progress_cf.id
474+
assert patch.current_commitfest().id == regular_cf.id
475+
assert patch.current_commitfest().id != draft_cf.id
490476

491477

492478
def test_draft_cf_moves_active_patches_to_next_draft(alice, bob, topic):

0 commit comments

Comments
 (0)