|
6 | 6 | from django.core.management import call_command |
7 | 7 | from django.test import TestCase |
8 | 8 |
|
| 9 | +from acl.models import Location |
9 | 10 | from agenda.models import Agenda |
10 | 11 | from chores.tests.factories import UserFactory |
11 | 12 |
|
@@ -38,3 +39,30 @@ def test_agenda_generate_recurring_events(self): |
38 | 39 | # Verify that no emails were sent for automatically generated chores |
39 | 40 | self.assertEqual(len(mail.outbox), 1) |
40 | 41 |
|
| 42 | + @time_machine.travel("2025-05-06 10:00") |
| 43 | + def test_agenda_generate_recurring_events_with_location(self): |
| 44 | + location = Location.objects.create(name="Test Location") |
| 45 | + |
| 46 | + # Add an Agenda item with a rrule defined |
| 47 | + Agenda.objects.create( |
| 48 | + user=self.user, |
| 49 | + item_title="Test Agenda", |
| 50 | + item_details="Test Description", |
| 51 | + startdatetime=datetime(2025, 5, 3, 8, 0, tzinfo=timezone.utc), |
| 52 | + enddatetime=datetime(2025, 5, 3, 16, 0, tzinfo=timezone.utc), |
| 53 | + recurrences="FREQ=DAILY;INTERVAL=1", |
| 54 | + location=location, |
| 55 | + ) |
| 56 | + |
| 57 | + stdout = StringIO() |
| 58 | + call_command("agenda_generate_recurring_events", stdout=stdout) |
| 59 | + call_command("agenda_generate_recurring_events", stdout=StringIO()) |
| 60 | + |
| 61 | + items = Agenda.objects.all() |
| 62 | + print(stdout.getvalue()) |
| 63 | + self.assertIn("Generated 31 recurring events", stdout.getvalue()) |
| 64 | + self.assertEqual(len(items), 32) |
| 65 | + |
| 66 | + # Verify that location is set on the generated agenda items |
| 67 | + for item in items: |
| 68 | + self.assertEqual(item.location, location) |
0 commit comments