From 1a133d33ff15bcbf83729dff5f79a25da8fb540c Mon Sep 17 00:00:00 2001 From: Matias Bordese Date: Tue, 6 Sep 2022 15:33:58 -0300 Subject: [PATCH] Add rotation ID fallback for ical events --- engine/apps/schedules/ical_utils.py | 3 +++ engine/apps/schedules/tests/test_ical_utils.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/engine/apps/schedules/ical_utils.py b/engine/apps/schedules/ical_utils.py index b9594ad9..8055558f 100644 --- a/engine/apps/schedules/ical_utils.py +++ b/engine/apps/schedules/ical_utils.py @@ -367,6 +367,9 @@ def parse_event_uid(string): match = RE_EVENT_UID_V1.match(string) if match: _, _, _, source = match.groups() + else: + # fallback to use the UID string as the rotation ID + pk = string if source is not None: source = int(source) diff --git a/engine/apps/schedules/tests/test_ical_utils.py b/engine/apps/schedules/tests/test_ical_utils.py index e7946617..38213be8 100644 --- a/engine/apps/schedules/tests/test_ical_utils.py +++ b/engine/apps/schedules/tests/test_ical_utils.py @@ -78,3 +78,11 @@ def test_parse_event_uid_v2(): pk, source = parse_event_uid(event_uid) assert pk == pk_value assert source == "slack" + + +def test_parse_event_uid_fallback(): + # use ical existing UID for imported events + event_uid = "someid@google.com" + pk, source = parse_event_uid(event_uid) + assert pk == event_uid + assert source is None