Build Forgejo-backed community prototype
This commit is contained in:
parent
797ae5ea35
commit
6671a01d26
16 changed files with 2485 additions and 293 deletions
42
tests/test_calendar_feeds.py
Normal file
42
tests/test_calendar_feeds.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from datetime import datetime, timedelta
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from calendar_feeds import _parse_ics
|
||||
|
||||
|
||||
class CalendarFeedTestCase(unittest.TestCase):
|
||||
def test_weekly_recurrence_returns_future_occurrences(self) -> None:
|
||||
timezone = ZoneInfo("America/New_York")
|
||||
starts_at = datetime.now(timezone).replace(
|
||||
hour=13,
|
||||
minute=0,
|
||||
second=0,
|
||||
microsecond=0,
|
||||
) - timedelta(days=7)
|
||||
ends_at = starts_at.replace(hour=16)
|
||||
raw_calendar = f"""BEGIN:VCALENDAR
|
||||
X-WR-CALNAME:Robot-U
|
||||
BEGIN:VEVENT
|
||||
SUMMARY:Robotics Club
|
||||
DTSTART;TZID=America/New_York:{starts_at.strftime("%Y%m%dT%H%M%S")}
|
||||
DTEND;TZID=America/New_York:{ends_at.strftime("%Y%m%dT%H%M%S")}
|
||||
RRULE:FREQ=WEEKLY
|
||||
LOCATION:44 Portland Street
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
"""
|
||||
|
||||
_calendar_name, events = _parse_ics(raw_calendar, "https://example.com/calendar.ics")
|
||||
|
||||
self.assertGreaterEqual(len(events), 1)
|
||||
self.assertEqual(events[0].title, "Robotics Club")
|
||||
self.assertGreaterEqual(events[0].starts_at, datetime.now(ZoneInfo("UTC")))
|
||||
self.assertEqual(events[0].starts_at.tzinfo, timezone)
|
||||
self.assertEqual(events[0].mode, "44 Portland Street")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue