1313 PatchHistory ,
1414 PatchOnCommitFest ,
1515 PendingNotification ,
16- Topic ,
1716)
1817from pgcommitfest .mailqueue .models import QueuedMail
1918from pgcommitfest .userprofile .models import UserProfile
@@ -31,17 +30,9 @@ def get_email_body(queued_mail):
3130 return ""
3231
3332
34- @pytest .fixture
35- def topic ():
36- """Create a test topic."""
37- return Topic .objects .create (topic = "General" )
38-
39-
40- def test_send_closure_notifications_to_authors_of_open_patches (
41- alice , in_progress_cf , topic
42- ):
33+ def test_send_closure_notifications_to_authors_of_open_patches (alice , in_progress_cf ):
4334 """Authors of patches with open status should receive closure notifications."""
44- patch = Patch .objects .create (name = "Test Patch" , topic = topic )
35+ patch = Patch .objects .create (name = "Test Patch" )
4536 patch .authors .add (alice )
4637 PatchOnCommitFest .objects .create (
4738 patch = patch ,
@@ -60,9 +51,9 @@ def test_send_closure_notifications_to_authors_of_open_patches(
6051 assert "Test Patch" in body
6152
6253
63- def test_no_notification_for_committed_patches (alice , in_progress_cf , topic ):
54+ def test_no_notification_for_committed_patches (alice , in_progress_cf ):
6455 """Authors of committed patches should not receive notifications."""
65- patch = Patch .objects .create (name = "Committed Patch" , topic = topic )
56+ patch = Patch .objects .create (name = "Committed Patch" )
6657 patch .authors .add (alice )
6758 PatchOnCommitFest .objects .create (
6859 patch = patch ,
@@ -77,11 +68,10 @@ def test_no_notification_for_committed_patches(alice, in_progress_cf, topic):
7768 assert QueuedMail .objects .count () == 0
7869
7970
80- def test_no_notification_for_withdrawn_patches (alice , in_progress_cf , open_cf , topic ):
71+ def test_no_notification_for_withdrawn_patches (alice , in_progress_cf , open_cf ):
8172 """Withdrawn patches should not receive notifications or be auto-moved."""
8273 patch = Patch .objects .create (
8374 name = "Withdrawn Patch" ,
84- topic = topic ,
8575 lastmail = datetime .now () - timedelta (days = 5 ),
8676 )
8777 patch .authors .add (alice )
@@ -99,9 +89,9 @@ def test_no_notification_for_withdrawn_patches(alice, in_progress_cf, open_cf, t
9989 assert QueuedMail .objects .count () == 0
10090
10191
102- def test_one_email_per_author_with_multiple_patches (alice , in_progress_cf , topic ):
92+ def test_one_email_per_author_with_multiple_patches (alice , in_progress_cf ):
10393 """An author with multiple open patches should receive one email listing all patches."""
104- patch1 = Patch .objects .create (name = "Patch One" , topic = topic )
94+ patch1 = Patch .objects .create (name = "Patch One" )
10595 patch1 .authors .add (alice )
10696 PatchOnCommitFest .objects .create (
10797 patch = patch1 ,
@@ -110,7 +100,7 @@ def test_one_email_per_author_with_multiple_patches(alice, in_progress_cf, topic
110100 status = PatchOnCommitFest .STATUS_REVIEW ,
111101 )
112102
113- patch2 = Patch .objects .create (name = "Patch Two" , topic = topic )
103+ patch2 = Patch .objects .create (name = "Patch Two" )
114104 patch2 .authors .add (alice )
115105 PatchOnCommitFest .objects .create (
116106 patch = patch2 ,
@@ -128,12 +118,12 @@ def test_one_email_per_author_with_multiple_patches(alice, in_progress_cf, topic
128118 assert "Patch Two" in body
129119
130120
131- def test_multiple_authors_receive_separate_emails (alice , bob , in_progress_cf , topic ):
121+ def test_multiple_authors_receive_separate_emails (alice , bob , in_progress_cf ):
132122 """Each author of open patches should receive their own notification (if opted in)."""
133123 # Bob also needs notify_all_author enabled to receive closure emails
134124 UserProfile .objects .create (user = bob , notify_all_author = True )
135125
136- patch1 = Patch .objects .create (name = "Alice Patch" , topic = topic )
126+ patch1 = Patch .objects .create (name = "Alice Patch" )
137127 patch1 .authors .add (alice )
138128 PatchOnCommitFest .objects .create (
139129 patch = patch1 ,
@@ -142,7 +132,7 @@ def test_multiple_authors_receive_separate_emails(alice, bob, in_progress_cf, to
142132 status = PatchOnCommitFest .STATUS_REVIEW ,
143133 )
144134
145- patch2 = Patch .objects .create (name = "Bob Patch" , topic = topic )
135+ patch2 = Patch .objects .create (name = "Bob Patch" )
146136 patch2 .authors .add (bob )
147137 PatchOnCommitFest .objects .create (
148138 patch = patch2 ,
@@ -158,32 +148,12 @@ def test_multiple_authors_receive_separate_emails(alice, bob, in_progress_cf, to
158148 assert receivers == {alice .email , bob .email }
159149
160150
161- def test_notification_includes_next_commitfest_info (
162- alice , in_progress_cf , open_cf , topic
163- ):
164- """Notification should include information about the next open commitfest."""
165- patch = Patch .objects .create (name = "Test Patch" , topic = topic )
166- patch .authors .add (alice )
167- PatchOnCommitFest .objects .create (
168- patch = patch ,
169- commitfest = in_progress_cf ,
170- enterdate = datetime .now (),
171- status = PatchOnCommitFest .STATUS_REVIEW ,
172- )
173-
174- in_progress_cf .send_closure_notifications ()
175-
176- mail = QueuedMail .objects .first ()
177- body = get_email_body (mail )
178- assert open_cf .name in body
179-
180-
181- def test_coauthors_both_receive_notification (alice , bob , in_progress_cf , topic ):
151+ def test_coauthors_both_receive_notification (alice , bob , in_progress_cf ):
182152 """Both co-authors of a patch should receive notifications (if opted in)."""
183153 # Bob also needs notify_all_author enabled to receive closure emails
184154 UserProfile .objects .create (user = bob , notify_all_author = True )
185155
186- patch = Patch .objects .create (name = "Coauthored Patch" , topic = topic )
156+ patch = Patch .objects .create (name = "Coauthored Patch" )
187157 patch .authors .add (alice )
188158 patch .authors .add (bob )
189159 PatchOnCommitFest .objects .create (
@@ -200,12 +170,10 @@ def test_coauthors_both_receive_notification(alice, bob, in_progress_cf, topic):
200170 assert receivers == {alice .email , bob .email }
201171
202172
203- def test_no_notification_for_author_without_notify_all_author (
204- bob , in_progress_cf , topic
205- ):
173+ def test_no_notification_for_author_without_notify_all_author (bob , in_progress_cf ):
206174 """Authors without notify_all_author enabled should not receive closure notifications."""
207175 # bob has no UserProfile, so notify_all_author is not enabled
208- patch = Patch .objects .create (name = "Test Patch" , topic = topic )
176+ patch = Patch .objects .create (name = "Test Patch" )
209177 patch .authors .add (bob )
210178 PatchOnCommitFest .objects .create (
211179 patch = patch ,
@@ -223,12 +191,11 @@ def test_no_notification_for_author_without_notify_all_author(
223191
224192
225193def test_auto_move_patch_with_recent_email_activity (
226- alice , bob , in_progress_cf , open_cf , topic
194+ alice , bob , in_progress_cf , open_cf
227195):
228196 """Patches with recent email activity should be auto-moved to the next commitfest."""
229197 patch = Patch .objects .create (
230198 name = "Active Patch" ,
231- topic = topic ,
232199 lastmail = datetime .now () - timedelta (days = 5 ),
233200 )
234201 patch .authors .add (alice )
@@ -261,11 +228,10 @@ def test_auto_move_patch_with_recent_email_activity(
261228 assert QueuedMail .objects .count () == 0
262229
263230
264- def test_no_auto_move_without_email_activity (alice , in_progress_cf , open_cf , topic ):
231+ def test_no_auto_move_without_email_activity (alice , in_progress_cf , open_cf ):
265232 """Patches without recent email activity should NOT be auto-moved."""
266233 patch = Patch .objects .create (
267234 name = "Inactive Patch" ,
268- topic = topic ,
269235 lastmail = datetime .now ()
270236 - timedelta (days = settings .AUTO_MOVE_EMAIL_ACTIVITY_DAYS + 10 ),
271237 )
@@ -292,11 +258,10 @@ def test_no_auto_move_without_email_activity(alice, in_progress_cf, open_cf, top
292258 assert "need" in body # "needs attention"
293259
294260
295- def test_no_auto_move_when_failing_too_long (alice , in_progress_cf , open_cf , topic ):
261+ def test_no_auto_move_when_failing_too_long (alice , in_progress_cf , open_cf ):
296262 """Patches failing CI for too long should NOT be auto-moved even with recent activity."""
297263 patch = Patch .objects .create (
298264 name = "Failing Patch" ,
299- topic = topic ,
300265 lastmail = datetime .now () - timedelta (days = 5 ),
301266 )
302267 patch .authors .add (alice )
@@ -326,11 +291,10 @@ def test_no_auto_move_when_failing_too_long(alice, in_progress_cf, open_cf, topi
326291 assert patch .current_commitfest ().id == in_progress_cf .id
327292
328293
329- def test_auto_move_when_failing_within_threshold (alice , in_progress_cf , open_cf , topic ):
294+ def test_auto_move_when_failing_within_threshold (alice , in_progress_cf , open_cf ):
330295 """Patches failing CI within the threshold should still be auto-moved."""
331296 patch = Patch .objects .create (
332297 name = "Recently Failing Patch" ,
333- topic = topic ,
334298 lastmail = datetime .now () - timedelta (days = 5 ),
335299 )
336300 patch .authors .add (alice )
@@ -363,11 +327,10 @@ def test_auto_move_when_failing_within_threshold(alice, in_progress_cf, open_cf,
363327 assert QueuedMail .objects .count () == 0
364328
365329
366- def test_no_auto_move_with_null_lastmail (alice , in_progress_cf , open_cf , topic ):
330+ def test_no_auto_move_with_null_lastmail (alice , in_progress_cf , open_cf ):
367331 """Patches with no email activity (null lastmail) should NOT be auto-moved."""
368332 patch = Patch .objects .create (
369333 name = "No Activity Patch" ,
370- topic = topic ,
371334 lastmail = None ,
372335 )
373336 patch .authors .add (alice )
@@ -384,11 +347,10 @@ def test_no_auto_move_with_null_lastmail(alice, in_progress_cf, open_cf, topic):
384347 assert patch .current_commitfest ().id == in_progress_cf .id
385348
386349
387- def test_auto_move_patch_without_cfbot_branch (alice , in_progress_cf , open_cf , topic ):
350+ def test_auto_move_patch_without_cfbot_branch (alice , in_progress_cf , open_cf ):
388351 """Patches with recent activity but no CI branch should be auto-moved."""
389352 patch = Patch .objects .create (
390353 name = "No CI Patch" ,
391- topic = topic ,
392354 lastmail = datetime .now () - timedelta (days = 5 ),
393355 )
394356 patch .authors .add (alice )
@@ -411,7 +373,7 @@ def test_auto_move_patch_without_cfbot_branch(alice, in_progress_cf, open_cf, to
411373 assert QueuedMail .objects .count () == 0
412374
413375
414- def test_regular_cf_does_not_move_to_draft_cf (alice , in_progress_cf , topic ):
376+ def test_regular_cf_does_not_move_to_draft_cf (alice , in_progress_cf ):
415377 """Regular commitfest should move patches to the next regular CF, not a draft CF."""
416378 # Create a draft CF - should be ignored for regular CF patches
417379 draft_cf = CommitFest .objects .create (
@@ -432,7 +394,6 @@ def test_regular_cf_does_not_move_to_draft_cf(alice, in_progress_cf, topic):
432394
433395 patch = Patch .objects .create (
434396 name = "Regular Patch" ,
435- topic = topic ,
436397 lastmail = datetime .now () - timedelta (days = 5 ),
437398 )
438399 patch .authors .add (alice )
@@ -451,7 +412,7 @@ def test_regular_cf_does_not_move_to_draft_cf(alice, in_progress_cf, topic):
451412 assert patch .current_commitfest ().id != draft_cf .id
452413
453414
454- def test_draft_cf_moves_active_patches_to_next_draft (alice , bob , topic ):
415+ def test_draft_cf_moves_active_patches_to_next_draft (alice , bob ):
455416 """Active patches in a draft commitfest should be auto-moved to the next draft CF."""
456417 # Create two draft CFs - one closing and one to receive patches
457418 closing_draft_cf = CommitFest .objects .create (
@@ -471,7 +432,6 @@ def test_draft_cf_moves_active_patches_to_next_draft(alice, bob, topic):
471432
472433 patch = Patch .objects .create (
473434 name = "Draft Patch" ,
474- topic = topic ,
475435 lastmail = datetime .now () - timedelta (days = 5 ),
476436 )
477437 patch .authors .add (alice )
0 commit comments