oncall-engine/engine/apps/schedules/tests/test_ical_proxy.py
Michael Derynck 6b40f95033 World, meet OnCall!
Co-authored-by: Eve832 <eve.meelan@grafana.com>
    Co-authored-by: Francisco Montes de Oca <nevermind89x@gmail.com>
    Co-authored-by: Ildar Iskhakov <ildar.iskhakov@grafana.com>
    Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
    Co-authored-by: Julia <ferril.darkdiver@gmail.com>
    Co-authored-by: maskin25 <kengurek@gmail.com>
    Co-authored-by: Matias Bordese <mbordese@gmail.com>
    Co-authored-by: Matvey Kukuy <motakuk@gmail.com>
    Co-authored-by: Michael Derynck <michael.derynck@grafana.com>
    Co-authored-by: Richard Hartmann <richih@richih.org>
    Co-authored-by: Robby Milo <robbymilo@fastmail.com>
    Co-authored-by: Timur Olzhabayev <timur.olzhabayev@grafana.com>
    Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
    Co-authored-by: Yulia Shanyrova <yulia.shanyrova@grafana.com>
2022-06-03 08:09:47 -06:00

52 lines
2 KiB
Python

from datetime import datetime
import pytz
from django.utils import timezone
from apps.schedules.ical_events import ical_events
def test_recurring_ical_events(get_ical):
calendar = get_ical("calendar_with_recurring_event.ics")
day_to_check_iso = "2021-01-27T15:27:14.448059+00:00"
day_to_check = timezone.datetime.fromisoformat(day_to_check_iso)
events = ical_events.get_events_from_ical_between(
calendar,
day_to_check - timezone.timedelta(days=1),
day_to_check + timezone.timedelta(days=1),
)
assert len(events) == 3
assert events[0]["SUMMARY"] == "@Bernard Desruisseaux"
assert events[1]["SUMMARY"] == "@Bernard Desruisseaux"
assert events[2]["SUMMARY"] == "@Bernard Desruisseaux"
def test_recurring_ical_events_with_edited_event(get_ical):
calendar = get_ical("calendar_with_edited_recurring_events.ics")
day_to_check_iso = "2021-01-27T15:27:14.448059+00:00"
day_to_check = timezone.datetime.fromisoformat(day_to_check_iso)
events = ical_events.get_events_from_ical_between(
calendar,
day_to_check - timezone.timedelta(days=1),
day_to_check + timezone.timedelta(days=1),
)
assert len(events) == 3
assert events[0]["SUMMARY"] == "@Bob"
assert events[1]["SUMMARY"] == "@Bernard Desruisseaux"
assert events[2]["SUMMARY"] == "@Bernard Desruisseaux"
def test_recurring_ical_events_with_all_day_event(get_ical):
calendar = get_ical("calendar_with_all_day_event.ics")
day_to_check_iso = "2021-01-27T15:27:14.448059+00:00"
parsed_iso_day_to_check = datetime.fromisoformat(day_to_check_iso).replace(tzinfo=pytz.UTC)
events = ical_events.get_events_from_ical_between(
calendar,
parsed_iso_day_to_check - timezone.timedelta(days=1),
parsed_iso_day_to_check + timezone.timedelta(days=1),
)
assert len(events) == 4
assert events[0]["SUMMARY"] == "@Alex"
assert events[1]["SUMMARY"] == "@Bob"
assert events[2]["SUMMARY"] == "@Bernard Desruisseaux"
assert events[3]["SUMMARY"] == "@Bernard Desruisseaux"