Exemplo n.º 1
0
    def test_import_from_ics__sync_keep_mine(self):
        """SYNC_KEEP_MINE and importing the same file again should do nothing.
        """
        self.portal.invokeFactory('Folder', 'impfolder3')
        impfolder = self.portal.impfolder3

        directory = os.path.dirname(__file__)
        icsfile = open(os.path.join(directory, 'icaltest.ics'), 'rb').read()

        res = ical_import(impfolder, icsfile, self.event_type)
        self.assertEqual(res['count'], 5)

        e1a = IEventAccessor(impfolder.e1)
        mod1 = e1a.last_modified
        suid1 = e1a.sync_uid

        res = ical_import(impfolder,
                          icsfile,
                          self.event_type,
                          sync_strategy=base.SYNC_KEEP_MINE)
        self.assertEqual(res['count'], 0)
        e1a = IEventAccessor(impfolder.e1)
        mod2 = e1a.last_modified
        suid2 = e1a.sync_uid

        self.assertEqual(len(impfolder.contentIds()), 5)

        self.assertEqual(mod1, mod2)
        self.assertEqual(suid1, suid2)
Exemplo n.º 2
0
    def test_import_from_ics__sync_keep_mine(self):
        """SYNC_KEEP_MINE and importing the same file again should do nothing.
        """
        self.portal.invokeFactory('Folder', 'impfolder3')
        impfolder = self.portal.impfolder3

        directory = os.path.dirname(__file__)
        with open(os.path.join(directory, 'icaltest.ics'), 'rb') as icsfile:
            icsdata = icsfile.read()

        res = ical_import(impfolder, icsdata, self.event_type)
        self.assertEqual(res['count'], 5)

        e1a = IEventAccessor(impfolder.e1)
        mod1 = e1a.last_modified
        suid1 = e1a.sync_uid

        res = ical_import(impfolder, icsdata, self.event_type,
                          sync_strategy=base.SYNC_KEEP_MINE)
        self.assertEqual(res['count'], 0)
        e1a = IEventAccessor(impfolder.e1)
        mod2 = e1a.last_modified
        suid2 = e1a.sync_uid

        self.assertEqual(len(impfolder.contentIds()), 5)

        self.assertEqual(mod1, mod2)
        self.assertEqual(suid1, suid2)
Exemplo n.º 3
0
    def test_import_from_ics__no_sync(self):
        """SYNC_NONE and importing the same file again should create new event
        objects and give them each a new sync_uid.
        """
        self.portal.invokeFactory('Folder', 'impfolder2')
        impfolder = self.portal.impfolder2

        directory = os.path.dirname(__file__)
        icsfile = open(os.path.join(directory, 'icaltest.ics'), 'rb').read()

        res = ical_import(impfolder, icsfile, self.event_type)
        self.assertEqual(res['count'], 5)

        e11 = impfolder['e1']
        suid1 = IEventAccessor(e11).sync_uid

        res = ical_import(impfolder,
                          icsfile,
                          self.event_type,
                          sync_strategy=base.SYNC_NONE)
        self.assertEqual(res['count'], 5)

        e12 = impfolder['e1-1']
        suid2 = IEventAccessor(e12).sync_uid

        self.assertEqual(len(impfolder.contentIds()), 10)
        self.assertNotEqual(suid1, suid2)
Exemplo n.º 4
0
    def test_import_from_ics__no_sync(self):
        """SYNC_NONE and importing the same file again should create new event
        objects and give them each a new sync_uid.
        """
        self.portal.invokeFactory('Folder', 'impfolder2')
        impfolder = self.portal.impfolder2

        directory = os.path.dirname(__file__)
        with open(os.path.join(directory, 'icaltest.ics'), 'rb') as icsfile:
            icsdata = icsfile.read()

        res = ical_import(impfolder, icsdata, self.event_type)

        self.assertEqual(res['count'], 5)

        e11 = impfolder['e1']
        suid1 = IEventAccessor(e11).sync_uid

        res = ical_import(impfolder, icsdata, self.event_type,
                          sync_strategy=base.SYNC_NONE)
        self.assertEqual(res['count'], 5)

        e12 = impfolder['e1-1']
        suid2 = IEventAccessor(e12).sync_uid

        self.assertEqual(len(impfolder.contentIds()), 10)
        self.assertNotEqual(suid1, suid2)
    def test_import_from_ics(self):
        # Ical import unit test.
        self.portal.invokeFactory('Folder', 'impfolder1')
        impfolder = self.portal.impfolder1

        directory = os.path.dirname(__file__)
        icsfile = open(os.path.join(directory, 'icaltest.ics'), 'rb').read()
        res = ical_import(impfolder, icsfile, self.event_type)

        self.assertEqual(res['count'], 5)
        self.assertEqual(len(impfolder.contentIds()), 5)

        at = pytz.timezone('Europe/Vienna')
        utc = pytz.utc

        # Use pydt to normalize for DST times.

        # TODO: test for attendees. see note in
        # plone.app.event.ical.importer.ical_import
        e1 = IEventAccessor(impfolder.e1)
        self.assertEqual(e1.start, at.localize(datetime(2013, 7, 19, 12, 0)))
        self.assertEqual(e1.end, at.localize(datetime(2013, 7, 20, 13, 0)))
        self.assertEqual(e1.description, 'A basic event with many properties.')
        self.assertEqual(e1.whole_day, False)
        self.assertEqual(e1.open_end, False)
        self.assertEqual(
            e1.sync_uid,
            u'48f1a7ad64e847568d860cd092344970',
        )

        e2 = IEventAccessor(impfolder.e2)
        self.assertEqual(e2.start, utc.localize(datetime(1996, 4, 1, 1, 0)))
        self.assertEqual(e2.end, utc.localize(datetime(1996, 4, 1, 2, 0)))
        self.assertEqual(
            e2.recurrence,
            u'RRULE:FREQ=DAILY;COUNT=100\nEXDATE:19960402T010000Z,'
            u'19960403T010000Z,19960404T010000Z')

        e3 = IEventAccessor(impfolder.e3)
        self.assertEqual(e3.start, at.localize(datetime(2012, 3, 27, 10, 0)))
        self.assertEqual(e3.end, at.localize(datetime(2012, 3, 27, 18, 0)))
        self.assertEqual(
            e3.recurrence,
            u'RRULE:FREQ=WEEKLY;UNTIL=20120703T080000Z;BYDAY=TU\n'
            u'EXDATE:20120529T100000,20120403T100000,20120410T100000,'
            u'20120501T100000,20120417T100000')

        e4 = IEventAccessor(impfolder.e4)
        self.assertEqual(e4.start, utc.localize(datetime(2013, 4, 4, 0, 0)))
        self.assertEqual(e4.end, utc.localize(datetime(2013, 4, 4, 23, 59,
                                                       59)))
        self.assertEqual(e4.whole_day, True)
        self.assertEqual(e4.open_end, False)

        e5 = IEventAccessor(impfolder.e5)
        self.assertEqual(e5.start, utc.localize(datetime(2013, 4, 2, 12, 0)))
        self.assertEqual(e5.end, utc.localize(datetime(2013, 4, 2, 23, 59,
                                                       59)))
        self.assertEqual(e5.whole_day, False)
        self.assertEqual(e5.open_end, True)
Exemplo n.º 6
0
    def test_import_from_ics__sync_drop_older(self):
        """SYNC_KEEP_NEWER and importing the same file again should update only
        newer and on equal modified date but drop the change when it is older.
        """
        self.portal.invokeFactory('Folder', 'impfolder4')
        impfolder = self.portal.impfolder4

        directory = os.path.dirname(__file__)
        with open(os.path.join(directory, 'icaltest.ics'), 'rb') as icsfile:
            icsdata1 = icsfile.read()

        with open(os.path.join(directory, 'icaltest2.ics'), 'rb') as icsfile:
            icsdata2 = icsfile.read()

        res = ical_import(impfolder, icsdata1, self.event_type)
        self.assertEqual(res['count'], 5)

        e1a = IEventAccessor(impfolder.e1)
        mod1 = e1a.last_modified
        suid1 = e1a.sync_uid
        title1 = e1a.title
        desc1 = e1a.description
        start1 = e1a.start
        end1 = e1a.end

        res = ical_import(impfolder,
                          icsdata2,
                          self.event_type,
                          sync_strategy=base.SYNC_KEEP_NEWER)
        self.assertEqual(res['count'], 4)
        e1a = IEventAccessor(impfolder.e1)
        mod2 = e1a.last_modified
        suid2 = e1a.sync_uid
        title2 = e1a.title
        desc2 = e1a.description
        start2 = e1a.start
        end2 = e1a.end

        self.assertEqual(len(impfolder.contentIds()), 5)

        self.assertTrue(mod1 < mod2)
        self.assertEqual(suid1, suid2)
        self.assertNotEqual(title1, title2)
        self.assertNotEqual(desc1, desc2)
        self.assertTrue(start1 < start2)
        self.assertTrue(end1 < end2)
Exemplo n.º 7
0
    def test_import_from_ics__sync_drop_older(self):
        """SYNC_KEEP_NEWER and importing the same file again should update only
        newer and on equal modified date but drop the change when it is older.
        """
        self.portal.invokeFactory('Folder', 'impfolder4')
        impfolder = self.portal.impfolder4

        directory = os.path.dirname(__file__)
        with open(os.path.join(directory, 'icaltest.ics'), 'rb') as icsfile:
            icsdata1 = icsfile.read()

        with open(os.path.join(directory, 'icaltest2.ics'), 'rb') as icsfile:
            icsdata2 = icsfile.read()

        res = ical_import(impfolder, icsdata1, self.event_type)
        self.assertEqual(res['count'], 5)

        e1a = IEventAccessor(impfolder.e1)
        mod1 = e1a.last_modified
        suid1 = e1a.sync_uid
        title1 = e1a.title
        desc1 = e1a.description
        start1 = e1a.start
        end1 = e1a.end

        res = ical_import(impfolder, icsdata2, self.event_type,
                          sync_strategy=base.SYNC_KEEP_NEWER)
        self.assertEqual(res['count'], 4)
        e1a = IEventAccessor(impfolder.e1)
        mod2 = e1a.last_modified
        suid2 = e1a.sync_uid
        title2 = e1a.title
        desc2 = e1a.description
        start2 = e1a.start
        end2 = e1a.end

        self.assertEqual(len(impfolder.contentIds()), 5)

        self.assertTrue(mod1 < mod2)
        self.assertEqual(suid1, suid2)
        self.assertNotEqual(title1, title2)
        self.assertNotEqual(desc1, desc2)
        self.assertTrue(start1 < start2)
        self.assertTrue(end1 < end2)
Exemplo n.º 8
0
    def test_import_from_ics__sync_keep_newer(self):
        """SYNC_KEEP_NEWER and importing the same file again should update only
        newer.
        """
        self.portal.invokeFactory('Folder', 'impfolder')
        impfolder = self.portal.impfolder

        directory = os.path.dirname(__file__)
        icsfile = open(os.path.join(directory, 'icaltest.ics'), 'rb').read()
        icsfile2 = open(os.path.join(directory, 'icaltest2.ics'), 'rb').read()

        res = ical_import(impfolder, icsfile, self.event_type)
        self.assertEqual(res['count'], 5)

        e1a = IEventAccessor(impfolder.e1)
        mod1 = e1a.last_modified
        suid1 = e1a.sync_uid
        title1 = e1a.title
        desc1 = e1a.description
        start1 = e1a.start
        end1 = e1a.end

        res = ical_import(impfolder, icsfile2, self.event_type,
                          sync_strategy=base.SYNC_KEEP_NEWER)
        self.assertEqual(res['count'], 1)
        e1a = IEventAccessor(impfolder.e1)
        mod2 = e1a.last_modified
        suid2 = e1a.sync_uid
        title2 = e1a.title
        desc2 = e1a.description
        start2 = e1a.start
        end2 = e1a.end

        self.assertEqual(len(impfolder.contentIds()), 5)

        self.assertTrue(mod1 < mod2)
        self.assertEqual(suid1, suid2)
        self.assertNotEqual(title1, title2)
        self.assertNotEqual(desc1, desc2)
        self.assertTrue(start1 < start2)
        self.assertTrue(end1 < end2)

        self.portal.manage_delObjects(['impfolder'])
Exemplo n.º 9
0
    def test_import_from_ics(self):
        # Ical import unit test.
        self.portal.invokeFactory("Folder", "impfolder1")
        impfolder = self.portal.impfolder1

        directory = os.path.dirname(__file__)
        icsfile = open(os.path.join(directory, "icaltest.ics"), "rb").read()
        res = ical_import(impfolder, icsfile, self.event_type)

        self.assertEqual(res["count"], 5)
        self.assertEqual(len(impfolder.contentIds()), 5)

        at = pytz.timezone("Europe/Vienna")
        utc = pytz.utc

        # Use pydt to normalize for DST times.

        # TODO: test for attendees. see note in
        # plone.app.event.ical.importer.ical_import
        e1 = IEventAccessor(impfolder.e1)
        self.assertEqual(e1.start, pydt(datetime(2013, 7, 19, 12, 0, tzinfo=at)))
        self.assertEqual(e1.end, pydt(datetime(2013, 7, 20, 13, 0, tzinfo=at)))
        self.assertEqual(e1.description, "A basic event with many properties.")
        self.assertEqual(e1.whole_day, False)
        self.assertEqual(e1.open_end, False)
        self.assertEqual(e1.sync_uid, u"48f1a7ad64e847568d860cd092344970")

        e2 = IEventAccessor(impfolder.e2)
        self.assertEqual(e2.start, pydt(datetime(1996, 4, 1, 1, 0, tzinfo=utc)))
        self.assertEqual(e2.end, pydt(datetime(1996, 4, 1, 2, 0, tzinfo=utc)))
        self.assertEqual(
            e2.recurrence, u"RRULE:FREQ=DAILY;COUNT=100\nEXDATE:19960402T010000Z," u"19960403T010000Z,19960404T010000Z"
        )

        e3 = IEventAccessor(impfolder.e3)
        self.assertEqual(e3.start, pydt(datetime(2012, 3, 27, 10, 0, tzinfo=at)))
        self.assertEqual(e3.end, pydt(datetime(2012, 3, 27, 18, 0, tzinfo=at)))
        self.assertEqual(
            e3.recurrence,
            u"RRULE:FREQ=WEEKLY;UNTIL=20120703T080000Z;BYDAY=TU\n"
            u"EXDATE:20120529T100000,20120403T100000,20120410T100000,"
            u"20120501T100000,20120417T100000",
        )

        e4 = IEventAccessor(impfolder.e4)
        self.assertEqual(e4.start, pydt(datetime(2013, 4, 4, 0, 0, tzinfo=utc)))
        self.assertEqual(e4.end, pydt(datetime(2013, 4, 4, 23, 59, 59, tzinfo=utc)))
        self.assertEqual(e4.whole_day, True)
        self.assertEqual(e4.open_end, False)

        e5 = IEventAccessor(impfolder.e5)
        self.assertEqual(e5.start, pydt(datetime(2013, 4, 2, 12, 0, tzinfo=utc)))
        self.assertEqual(e5.end, pydt(datetime(2013, 4, 2, 23, 59, 59, tzinfo=utc)))
        self.assertEqual(e5.whole_day, False)
        self.assertEqual(e5.open_end, True)
Exemplo n.º 10
0
    def PUT(self, REQUEST, RESPONSE):
        """PUT objects.
        """

        content_type = REQUEST.getHeader('Content-Type')
        if content_type != 'text/calendar':
            raise Exception('Unkown PUT content type: %s' % content_type)

        ical_data = REQUEST.get('BODY')
        ical_import(self.context, ical_data, 'plone.app.event.dx.event')

        cal = icalendar.Calendar.from_ical(ical_data)
        sync_uid = cal.walk('VEVENT')[0].decoded('UID')
        catalog = getToolByName(self.context, 'portal_catalog')
        brain = catalog(sync_uid=sync_uid,
                        path={'query': '/'.join(self.context.getPhysicalPath()),
                              'depth': 1})[0]
        RESPONSE.setHeader('ETag', '"%s"' % brain.UID)

        RESPONSE.setStatus(201)
        return RESPONSE
Exemplo n.º 11
0
    def test_import_from_ics__no_sync(self):
        """SYNC_NONE and importing the same file again should create new event
        objects and give them each a new sync_uid.
        """
        self.portal.invokeFactory("Folder", "impfolder2")
        impfolder = self.portal.impfolder2

        directory = os.path.dirname(__file__)
        icsfile = open(os.path.join(directory, "icaltest.ics"), "rb").read()

        res = ical_import(impfolder, icsfile, self.event_type)
        self.assertEqual(res["count"], 5)

        e11 = impfolder["e1"]
        suid1 = IEventAccessor(e11).sync_uid

        res = ical_import(impfolder, icsfile, self.event_type, sync_strategy=base.SYNC_NONE)
        self.assertEqual(res["count"], 5)

        e12 = impfolder["e1-1"]
        suid2 = IEventAccessor(e12).sync_uid

        self.assertEqual(len(impfolder.contentIds()), 10)
        self.assertNotEqual(suid1, suid2)
Exemplo n.º 12
0
    def test_import_from_ics__sync_keep_theirs(self):
        """SYNC_KEEP_THEIRS and importing the same file again should update
        all.
        """
        self.portal.invokeFactory('Folder', 'impfolder5')
        impfolder = self.portal.impfolder5

        directory = os.path.dirname(__file__)
        icsfile = open(os.path.join(directory, 'icaltest.ics'), 'rb').read()
        icsfile2 = open(os.path.join(directory, 'icaltest2.ics'), 'rb').read()

        res = ical_import(impfolder, icsfile, self.event_type)
        self.assertEqual(res['count'], 5)

        e1a = IEventAccessor(impfolder.e1)
        mod11 = e1a.last_modified
        suid11 = e1a.sync_uid
        title11 = e1a.title
        desc11 = e1a.description
        start11 = e1a.start
        end11 = e1a.end

        e2a = IEventAccessor(impfolder.e2)
        suid21 = e2a.sync_uid
        title21 = e2a.title
        desc21 = e2a.description
        start21 = e2a.start
        end21 = e2a.end

        res = ical_import(impfolder,
                          icsfile2,
                          self.event_type,
                          sync_strategy=base.SYNC_KEEP_THEIRS)
        self.assertEqual(res['count'], 5)

        e1a = IEventAccessor(impfolder.e1)
        mod12 = e1a.last_modified
        suid12 = e1a.sync_uid
        title12 = e1a.title
        desc12 = e1a.description
        start12 = e1a.start
        end12 = e1a.end

        e2a = IEventAccessor(impfolder.e2)
        suid22 = e2a.sync_uid
        title22 = e2a.title
        desc22 = e2a.description
        start22 = e2a.start
        end22 = e2a.end

        self.assertEqual(len(impfolder.contentIds()), 5)

        self.assertTrue(mod11 < mod12)
        self.assertEqual(suid11, suid12)
        self.assertNotEqual(title11, title12)
        self.assertNotEqual(desc11, desc12)
        self.assertTrue(start11 < start12)
        self.assertTrue(end11 < end12)

        self.assertEqual(suid21, suid22)
        self.assertNotEqual(title21, title22)
        self.assertNotEqual(desc21, desc22)
        self.assertTrue(start21 < start22)
        self.assertTrue(end21 < end22)
Exemplo n.º 13
0
    def test_import_from_ics__sync_keep_theirs(self):
        """SYNC_KEEP_THEIRS and importing the same file again should update
        all.
        """
        self.portal.invokeFactory('Folder', 'impfolder5')
        impfolder = self.portal.impfolder5

        directory = os.path.dirname(__file__)

        with open(os.path.join(directory, 'icaltest.ics'), 'rb') as icsfile:
            icsdata1 = icsfile.read()

        with open(os.path.join(directory, 'icaltest2.ics'), 'rb') as icsfile:
            icsdata2 = icsfile.read()

        res = ical_import(impfolder, icsdata1, self.event_type)
        self.assertEqual(res['count'], 5)

        e1a = IEventAccessor(impfolder.e1)
        mod11 = e1a.last_modified
        suid11 = e1a.sync_uid
        title11 = e1a.title
        desc11 = e1a.description
        start11 = e1a.start
        end11 = e1a.end

        e2a = IEventAccessor(impfolder.e2)
        suid21 = e2a.sync_uid
        title21 = e2a.title
        desc21 = e2a.description
        start21 = e2a.start
        end21 = e2a.end

        res = ical_import(impfolder, icsdata2, self.event_type,
                          sync_strategy=base.SYNC_KEEP_THEIRS)
        self.assertEqual(res['count'], 5)

        e1a = IEventAccessor(impfolder.e1)
        mod12 = e1a.last_modified
        suid12 = e1a.sync_uid
        title12 = e1a.title
        desc12 = e1a.description
        start12 = e1a.start
        end12 = e1a.end

        e2a = IEventAccessor(impfolder.e2)
        suid22 = e2a.sync_uid
        title22 = e2a.title
        desc22 = e2a.description
        start22 = e2a.start
        end22 = e2a.end

        self.assertEqual(len(impfolder.contentIds()), 5)

        self.assertTrue(mod11 < mod12)
        self.assertEqual(suid11, suid12)
        self.assertNotEqual(title11, title12)
        self.assertNotEqual(desc11, desc12)
        self.assertTrue(start11 < start12)
        self.assertTrue(end11 < end12)

        self.assertEqual(suid21, suid22)
        self.assertNotEqual(title21, title22)
        self.assertNotEqual(desc21, desc22)
        self.assertTrue(start21 < start22)
        self.assertTrue(end21 < end22)
Exemplo n.º 14
0
    def test_import_from_ics(self):
        # Ical import unit test.
        self.portal.invokeFactory('Folder', 'impfolder1')
        impfolder = self.portal.impfolder1

        directory = os.path.dirname(__file__)
        with open(os.path.join(directory, 'icaltest.ics'), 'rb') as icsfile:
            icsdata = icsfile.read()
        res = ical_import(impfolder, icsdata, self.event_type)

        self.assertEqual(res['count'], 5)
        self.assertEqual(len(impfolder.contentIds()), 5)

        at = pytz.timezone('Europe/Vienna')
        utc = pytz.utc

        # Use pydt to normalize for DST times.

        # TODO: test for attendees. see note in
        # plone.app.event.ical.importer.ical_import
        e1 = IEventAccessor(impfolder.e1)
        self.assertEqual(
            e1.start,
            at.localize(datetime(2013, 7, 19, 12, 0))
        )
        self.assertEqual(
            e1.end,
            at.localize(datetime(2013, 7, 20, 13, 0))
        )
        self.assertEqual(
            e1.description,
            'A basic event with many properties.'
        )
        self.assertEqual(
            e1.whole_day,
            False
        )
        self.assertEqual(
            e1.open_end,
            False
        )
        self.assertEqual(
            e1.sync_uid,
            u'48f1a7ad64e847568d860cd092344970',
        )

        e2 = IEventAccessor(impfolder.e2)
        self.assertEqual(
            e2.start,
            utc.localize(datetime(1996, 4, 1, 1, 0))
        )
        self.assertEqual(
            e2.end,
            utc.localize(datetime(1996, 4, 1, 2, 0))
        )
        self.assertEqual(
            e2.recurrence,
            u'RRULE:FREQ=DAILY;COUNT=100\nEXDATE:19960402T010000Z,'
            u'19960403T010000Z,19960404T010000Z'
        )

        e3 = IEventAccessor(impfolder.e3)
        self.assertEqual(
            e3.start,
            at.localize(datetime(2012, 3, 27, 10, 0))
        )
        self.assertEqual(
            e3.end,
            at.localize(datetime(2012, 3, 27, 18, 0))
        )
        self.assertEqual(
            e3.recurrence,
            u'RRULE:FREQ=WEEKLY;UNTIL=20120703T080000Z;BYDAY=TU\n'
            u'EXDATE:20120529T100000,20120403T100000,20120410T100000,'
            u'20120501T100000,20120417T100000'
        )

        e4 = IEventAccessor(impfolder.e4)
        self.assertEqual(
            e4.start,
            utc.localize(datetime(2013, 4, 4, 0, 0))
        )
        self.assertEqual(
            e4.end,
            utc.localize(datetime(2013, 4, 4, 23, 59, 59))
        )
        self.assertEqual(
            e4.whole_day,
            True
        )
        self.assertEqual(
            e4.open_end,
            False
        )

        e5 = IEventAccessor(impfolder.e5)
        self.assertEqual(
            e5.start,
            utc.localize(datetime(2013, 4, 2, 12, 0))
        )
        self.assertEqual(
            e5.end,
            utc.localize(datetime(2013, 4, 2, 23, 59, 59))
        )
        self.assertEqual(
            e5.whole_day,
            False
        )
        self.assertEqual(
            e5.open_end,
            True
        )
Exemplo n.º 15
0
    def test_import_from_ics(self):
        # Ical import unit test.

        directory = os.path.dirname(__file__)
        icsfile = open(os.path.join(directory, 'icaltest.ics'), 'rb').read()
        res = ical_import(self.impfolder, icsfile, 'plone.app.event.dx.event')

        self.assertEqual(res['count'], 5)

        at = pytz.timezone('Europe/Vienna')
        utc = pytz.utc

        e1 = IEventAccessor(self.impfolder.e1)

        # Use pydt to normalize for DST times.

        # TODO: test for attendees. see note in
        # plone.app.event.ical.importer.ical_import
        self.assertEqual(
            e1.start,
            pydt(datetime(2013, 7, 19, 12, 0, tzinfo=at))
        )
        self.assertEqual(
            e1.end,
            pydt(datetime(2013, 7, 20, 13, 0, tzinfo=at))
        )
        self.assertEqual(
            e1.description,
            'A basic event with many properties.'
        )
        self.assertEqual(
            e1.whole_day,
            False
        )
        self.assertEqual(
            e1.open_end,
            False
        )


        e2 = IEventAccessor(self.impfolder.e2)
        self.assertEqual(
            e2.start,
            pydt(datetime(1996, 4, 1, 1, 0, tzinfo=utc))
        )
        self.assertEqual(
            e2.end,
            pydt(datetime(1996, 4, 1, 2, 0, tzinfo=utc))
        )
        self.assertEqual(
            e2.recurrence,
            u'RRULE:FREQ=DAILY;COUNT=100\nEXDATE:19960402T010000Z,19960403T010000Z,19960404T010000Z'
        )

        e3 = IEventAccessor(self.impfolder.e3)
        self.assertEqual(
            e3.start,
            pydt(datetime(2012, 3, 27, 10, 0, tzinfo=at))
        )
        self.assertEqual(
            e3.end,
            pydt(datetime(2012, 3, 27, 18, 0, tzinfo=at))
        )
        self.assertEqual(
            e3.recurrence,
            u'RRULE:FREQ=WEEKLY;UNTIL=20120703T080000Z;BYDAY=TU\nEXDATE:20120529T100000,20120403T100000,20120410T100000,20120501T100000,20120417T100000'
        )


        e4 = IEventAccessor(self.impfolder.e4)
        self.assertEqual(
            e4.start,
            pydt(datetime(2013, 4, 4, 0, 0, tzinfo=utc))
        )
        self.assertEqual(
            e4.end,
            pydt(datetime(2013, 4, 4, 23, 59, 59, tzinfo=utc))
        )
        self.assertEqual(
            e4.whole_day,
            True
        )
        self.assertEqual(
            e4.open_end,
            False
        )


        e5 = IEventAccessor(self.impfolder.e5)
        self.assertEqual(
            e5.start,
            pydt(datetime(2013, 4, 2, 12, 0, tzinfo=utc))
        )
        self.assertEqual(
            e5.end,
            pydt(datetime(2013, 4, 2, 23, 59, 59, tzinfo=utc))
        )
        self.assertEqual(
            e5.whole_day,
            False
        )
        self.assertEqual(
            e5.open_end,
            True
        )