From 337a585a94acd266122bc78646bc5592ba6f5e96 Mon Sep 17 00:00:00 2001 From: David Slusser Date: Sun, 20 Sep 2026 17:05:46 -0700 Subject: [PATCH] adding protection for groups without a platform link --- src/django_project/tests/unit/web/test_tasks.py | 9 +++++++++ src/django_project/web/tasks.py | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/django_project/tests/unit/web/test_tasks.py b/src/django_project/tests/unit/web/test_tasks.py index dbebf3b..b03a543 100644 --- a/src/django_project/tests/unit/web/test_tasks.py +++ b/src/django_project/tests/unit/web/test_tasks.py @@ -27,6 +27,15 @@ def setUp(self): ) self.group.links.add(self.link) + @patch("web.tasks.get_events_for_organization") + def test_returns_clear_result_when_platform_link_is_missing(self, mock_get_events_for_organization): + self.group.links.remove(self.link) + + result = ingest_future_eventbrite_events(self.group.pk) + + self.assertEqual(result, f"no Eventbrite links found for {self.group.name}") + mock_get_events_for_organization.assert_not_called() + @patch("web.tasks.get_event_details") @patch("web.tasks.get_events_for_organization") def test_ingests_event_without_primary_venue(self, mock_get_events_for_organization, mock_get_event_details): diff --git a/src/django_project/web/tasks.py b/src/django_project/web/tasks.py index c6ce1f9..432210c 100644 --- a/src/django_project/web/tasks.py +++ b/src/django_project/web/tasks.py @@ -142,7 +142,9 @@ def ingest_future_eventbrite_events(group_pk) -> str: if not group: return f"group with pk {group_pk} not found" event_count = 0 - link: Any = group.links.filter(name=f"{group.name} {group.platform.name} page").distinct()[0] + link: Any = group.links.filter(name=f"{group.name} {group.platform.name} page").distinct().first() + if not link: + return f"no {group.platform.name} links found for {group.name}" eb_group_id: str = link.url.split("-")[-1] event_list: list = get_events_for_organization(eb_group_id) for item in event_list: