/usr/lib/python3/dist-packages/icalendar/tests/test_recurrence.py is in python3-icalendar 4.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # -*- coding: utf-8 -*-
from icalendar.caselessdict import CaselessDict
import unittest
import datetime
import icalendar
import os
import pytz
class TestRecurrence(unittest.TestCase):
def setUp(self):
directory = os.path.dirname(__file__)
with open(os.path.join(directory, 'recurrence.ics'), 'rb') as fp:
data = fp.read()
self.cal = icalendar.Calendar.from_ical(data)
def test_recurrence_exdates_one_line(self):
first_event = self.cal.walk('vevent')[0]
self.assertIsInstance(first_event, CaselessDict)
self.assertEqual(
first_event['rrule'], {'COUNT': [100], 'FREQ': ['DAILY']}
)
self.assertEqual(
first_event['exdate'].to_ical(),
b'19960402T010000Z,19960403T010000Z,19960404T010000Z'
)
self.assertEqual(
first_event['exdate'].dts[0].dt,
pytz.utc.localize(datetime.datetime(1996, 4, 2, 1, 0))
)
self.assertEqual(
first_event['exdate'].dts[1].dt,
pytz.utc.localize(datetime.datetime(1996, 4, 3, 1, 0))
)
self.assertEqual(
first_event['exdate'].dts[2].dt,
pytz.utc.localize(datetime.datetime(1996, 4, 4, 1, 0))
)
def test_recurrence_exdates_multiple_lines(self):
event = self.cal.walk('vevent')[1]
exdate = event['exdate']
# TODO: DOCUMENT BETTER!
# In this case we have multiple EXDATE definitions, one per line.
# Icalendar makes a list out of this instead of zipping it into one
# vDDDLists object. Actually, this feels correct for me, as it also
# allows to define different timezones per exdate line - but client
# code has to handle this as list and not blindly expecting to be able
# to call event['EXDATE'].to_ical() on it:
self.assertEqual(isinstance(exdate, list), True) # multiple EXDATE
self.assertEqual(exdate[0].to_ical(), b'20120529T100000')
# TODO: test for embedded timezone information!
|