|
10 | 10 |
|
11 | 11 | from members.models import User |
12 | 12 |
|
13 | | -from .models import Chore, ChoreNotification, ChoreVolunteer |
| 13 | +from ..models import Chore, ChoreNotification, ChoreVolunteer |
14 | 14 |
|
15 | 15 |
|
16 | 16 | class CustomCommandTest(TestCase): |
@@ -247,171 +247,6 @@ def test_email_reminding_volunteers(self): |
247 | 247 | self.assertIn("Volunteering reminder", email.subject) |
248 | 248 | self.assertIn("friendly reminder that you signed up for", email.body) |
249 | 249 |
|
250 | | - |
251 | | -class ChoreModelTest(TestCase): |
252 | | - def setUp(self): |
253 | | - self.user = User.objects.create_user( |
254 | | - |
255 | | - password="testpass123", |
256 | | - first_name="Test", |
257 | | - last_name="User", |
258 | | - ) |
259 | | - |
260 | | - def test_chore_creation(self): |
261 | | - """Test basic chore creation""" |
262 | | - chore = Chore.objects.create( |
263 | | - name="Test Chore", |
264 | | - description="A test chore", |
265 | | - class_type="BasicChore", |
266 | | - configuration={"min_required_people": 1}, |
267 | | - creator=self.user, |
268 | | - ) |
269 | | - self.assertEqual(chore.name, "Test Chore") |
270 | | - self.assertEqual(chore.description, "A test chore") |
271 | | - self.assertEqual(chore.class_type, "BasicChore") |
272 | | - self.assertEqual(chore.creator, self.user) |
273 | | - |
274 | | - def test_chore_str_representation(self): |
275 | | - """Test string representation of chore""" |
276 | | - chore = Chore.objects.create( |
277 | | - name="Test Chore", |
278 | | - description="A test chore", |
279 | | - class_type="BasicChore", |
280 | | - configuration={"min_required_people": 1}, |
281 | | - creator=self.user, |
282 | | - ) |
283 | | - self.assertEqual(str(chore), "Test Chore") |
284 | | - |
285 | | - def test_chore_unique_name_constraint(self): |
286 | | - """Test that chore names must be unique""" |
287 | | - Chore.objects.create( |
288 | | - name="Test Chore", |
289 | | - description="A test chore", |
290 | | - class_type="BasicChore", |
291 | | - configuration={"min_required_people": 1}, |
292 | | - creator=self.user, |
293 | | - ) |
294 | | - |
295 | | - with self.assertRaises(Exception): # Should raise IntegrityError |
296 | | - Chore.objects.create( |
297 | | - name="Test Chore", # Same name |
298 | | - description="Another test chore", |
299 | | - class_type="BasicChore", |
300 | | - configuration={"min_required_people": 1}, |
301 | | - creator=self.user, |
302 | | - ) |
303 | | - |
304 | | - |
305 | | -class ChoreVolunteerModelTest(TestCase): |
306 | | - def setUp(self): |
307 | | - self.user = User.objects.create_user( |
308 | | - |
309 | | - password="testpass123", |
310 | | - first_name="Test", |
311 | | - last_name="User", |
312 | | - ) |
313 | | - self.chore = Chore.objects.create( |
314 | | - name="Test Chore", |
315 | | - description="A test chore", |
316 | | - class_type="BasicChore", |
317 | | - configuration={"min_required_people": 1}, |
318 | | - creator=self.user, |
319 | | - ) |
320 | | - |
321 | | - def test_chore_volunteer_creation(self): |
322 | | - """Test basic chore volunteer creation""" |
323 | | - volunteer = ChoreVolunteer.objects.create( |
324 | | - user=self.user, |
325 | | - chore=self.chore, |
326 | | - timestamp=1753041600, |
327 | | - ) |
328 | | - self.assertEqual(volunteer.user, self.user) |
329 | | - self.assertEqual(volunteer.chore, self.chore) |
330 | | - self.assertEqual(volunteer.timestamp, 1753041600) |
331 | | - |
332 | | - def test_chore_volunteer_properties(self): |
333 | | - """Test chore volunteer properties""" |
334 | | - volunteer = ChoreVolunteer.objects.create( |
335 | | - user=self.user, |
336 | | - chore=self.chore, |
337 | | - timestamp=1753041600, |
338 | | - ) |
339 | | - self.assertEqual(volunteer.first_name, "Test") |
340 | | - self.assertEqual(volunteer.full_name, "Test User") |
341 | | - |
342 | | - |
343 | | -class ChoreNotificationModelTest(TestCase): |
344 | | - def setUp(self): |
345 | | - self.user = User.objects.create_user( |
346 | | - |
347 | | - password="testpass123", |
348 | | - first_name="Test", |
349 | | - last_name="User", |
350 | | - ) |
351 | | - self.chore = Chore.objects.create( |
352 | | - name="Test Chore", |
353 | | - description="A test chore", |
354 | | - class_type="BasicChore", |
355 | | - configuration={"min_required_people": 1}, |
356 | | - creator=self.user, |
357 | | - ) |
358 | | - |
359 | | - def test_notification_with_user_recipient(self): |
360 | | - """Test notification creation with user recipient""" |
361 | | - notification = ChoreNotification.objects.create( |
362 | | - event_key="test-key-123", |
363 | | - chore=self.chore, |
364 | | - recipient_user=self.user, |
365 | | - ) |
366 | | - self.assertEqual(notification.event_key, "test-key-123") |
367 | | - self.assertEqual(notification.chore, self.chore) |
368 | | - self.assertEqual(notification.recipient_user, self.user) |
369 | | - self.assertIsNone(notification.recipient_other) |
370 | | - |
371 | | - def test_notification_with_email_recipient(self): |
372 | | - """Test notification creation with email recipient""" |
373 | | - notification = ChoreNotification.objects.create( |
374 | | - event_key="test-key-456", |
375 | | - chore=self.chore, |
376 | | - recipient_other="[email protected]", |
377 | | - ) |
378 | | - self.assertEqual(notification.event_key, "test-key-456") |
379 | | - self.assertEqual(notification.chore, self.chore) |
380 | | - self.assertIsNone(notification.recipient_user) |
381 | | - self. assertEqual( notification. recipient_other, "[email protected]") |
382 | | - |
383 | | - def test_notification_validation_both_recipients(self): |
384 | | - """Test that notification cannot have both user and email recipients""" |
385 | | - notification = ChoreNotification( |
386 | | - event_key="test-key-789", |
387 | | - chore=self.chore, |
388 | | - recipient_user=self.user, |
389 | | - recipient_other="[email protected]", |
390 | | - ) |
391 | | - with self.assertRaises(ValidationError): |
392 | | - notification.clean() |
393 | | - |
394 | | - def test_notification_validation_no_recipients(self): |
395 | | - """Test that notification must have at least one recipient""" |
396 | | - notification = ChoreNotification( |
397 | | - event_key="test-key-789", |
398 | | - chore=self.chore, |
399 | | - ) |
400 | | - with self.assertRaises(ValidationError): |
401 | | - notification.clean() |
402 | | - |
403 | | - def test_notification_str_representation(self): |
404 | | - """Test string representation of notification""" |
405 | | - notification = ChoreNotification.objects.create( |
406 | | - event_key="test-key-123", |
407 | | - chore=self.chore, |
408 | | - recipient_user=self.user, |
409 | | - ) |
410 | | - self.assertIn("Notification to", str(notification)) |
411 | | - self.assertIn("Test User", str(notification)) |
412 | | - self.assertIn("Test Chore", str(notification)) |
413 | | - |
414 | | - |
415 | 250 | class SingleOccurrenceChoreTest(TestCase): |
416 | 251 | def setUp(self): |
417 | 252 | self.user = User.objects.create_user( |
@@ -920,9 +755,6 @@ def test_volunteer_cross_contamination_defect(self): |
920 | 755 | out = StringIO() |
921 | 756 | call_command("send_reminders", stdout=out) |
922 | 757 |
|
923 | | - # DEFECT: Due to ChoreVolunteer.objects.all() query, chore2 should NOT get a reminder |
924 | | - # because the volunteer from chore1 is incorrectly counted for chore2 |
925 | 758 | # Verify that chore2 should have gotten a reminder if the bug was fixed |
926 | | - # (This assertion documents the expected correct behavior) |
927 | 759 | self.assertEqual(len(mail.outbox), 1) |
928 | 760 | self.assertIn("Chore 2 needs volunteers", mail.outbox[0].subject) |
0 commit comments