From 4fdf13f4eb7d2f1309eedef4d7eb6a66a21e7edb Mon Sep 17 00:00:00 2001 From: Jordan Kiang Date: Thu, 3 Apr 2014 12:10:03 -0700 Subject: [PATCH] revise tests, rm test for 114 which doesnt apply if vevents ignore_exceptions and add replacement tests --- .../tests/issue_114_invalid_line.ics | 41 -------------- src/icalendar/tests/test_fixed_issues.py | 56 +++++++++++++++---- 2 files changed, 44 insertions(+), 53 deletions(-) delete mode 100644 src/icalendar/tests/issue_114_invalid_line.ics diff --git a/src/icalendar/tests/issue_114_invalid_line.ics b/src/icalendar/tests/issue_114_invalid_line.ics deleted file mode 100644 index 53965f0..0000000 --- a/src/icalendar/tests/issue_114_invalid_line.ics +++ /dev/null @@ -1,41 +0,0 @@ -BEGIN:VEVENT -DTSTART:20130927T130000Z -DTEND:20130927T140000Z -DTSTAMP:20131107T004757Z -ORGANIZER;CN=gxxxxxxxn@nxx.fr:mailto:gxxxxxn@nxx.fr -UID:040000008200E00074C5B7101A82E00800000000A0F3321606B6CE01000000000000000 - 010000000F09F33F0E8ED4C44B99F6027ACF588D0 -ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;CN=St - eve Bxxxxxx;X-NUM-GUESTS=0:mailto:sxxxxxt@nxx.fr -ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Boris - Hxxxxx;X-NUM-GUESTS=0:mailto:bxxxxxxk@vxxxxxxxx.com -CREATED:20130920T113409Z -DESCRIPTION:Quand : vendredi 27 septembre 2013 15:00-16:00 (UTC+01:00) Brux - elles\, Copenhague\, Madrid\, Paris.\nEmplacement : Conf-Call - 01 xx xx xx - xx\n\nRemarque : le décalage GMT ci-dessus ne tient pas compte des réglage - s de l'heure d'été.\n\n*~*~*~*~*~*~*~*~*~*\n\nComme convenu à l’instant par - e-mail\n -LAST-MODIFIED:20130920T115104Z -LOCATION:Conf-Call - 01 xx xx xx xx -SEQUENCE:0 -STATUS:CONFIRMED -SUMMARY:Nxx - Réunion lancement PxxxxxxT -TRANSP:OPAQUE -X-ALT-DESC;FMTTYPE=text/html:\n\n\n\n\n\n\n\n\n

Qu - and : vendredi 27 septembre 2013 15:00-16:00 (UTC+01:00) Bruxelles\, Copenh - ague\, Madrid\, Paris.

\n\n

Emplacement : Conf-Call - 01 xx xx xx xx

- \n\n

Remarque : le décalage - GMT ci-dessus ne tient pas compte des réglages de l'heure d'été.

\n\n

*~*~*~*~*~*~*~*~ - *~*

\n\n

Co - mme convenu à l’instant par e-mail

- \n\n\n -X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE -X-MICROSOFT-CDO-IMPORTANCE:1 -X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY -X -END:VEVENT diff --git a/src/icalendar/tests/test_fixed_issues.py b/src/icalendar/tests/test_fixed_issues.py index c860d71..747eb61 100644 --- a/src/icalendar/tests/test_fixed_issues.py +++ b/src/icalendar/tests/test_fixed_issues.py @@ -180,6 +180,50 @@ END:VCALENDAR""" org_cn = cal.walk('VEVENT')[0]['ORGANIZER'].params['CN'] self.assertEqual(org_cn, u'acme, ädmin') + def test_issue_104__ignore_exceptions(self): + """ + Issue #104 - line parsing error in a VEVENT + (which has ignore_exceptions). Should mark the event broken + but not raise an exception. + https://github.com/collective/icalendar/issues/104 + """ + ical_str = """ +BEGIN:VEVENT +DTSTART:20140401T000000Z +DTEND:20140401T010000Z +DTSTAMP:20140401T000000Z +SUMMARY:Broken Eevnt +CLASS:PUBLIC +STATUS:CONFIRMED +TRANSP:OPAQUE +X +END:VEVENT""" + event = icalendar.Calendar.from_ical(ical_str) + self.assertTrue(isinstance(event, icalendar.Event)) + self.assertTrue(event.is_broken) + + def test_issue_104__no_ignore_exceptions(self): + """ + Issue #104 - line parsing error in a VCALENDAR + (which doesn't have ignore_exceptions). Should raise an exception. + """ + ical_str = """BEGIN:VCALENDAR +VERSION:2.0 +METHOD:PUBLISH +BEGIN:VEVENT +DTSTART:20140401T000000Z +DTEND:20140401T010000Z +DTSTAMP:20140401T000000Z +SUMMARY:Broken Eevnt +CLASS:PUBLIC +STATUS:CONFIRMED +TRANSP:OPAQUE +END:VEVENT +X +END:VCALENDAR""" + with self.assertRaises(ValueError): + icalendar.Calendar.from_ical(ical_str) + def test_issue_112(self): """Issue #112 - No timezone info on EXDATE https://github.com/collective/icalendar/issues/112 @@ -206,18 +250,6 @@ END:VCALENDAR""" self.assertEqual(event['exdate'][0].dts[0].dt.tzname(), 'EDT') - def test_issue_114(self): - """Issue #114/#115 - invalid line in event breaks the parser - https://github.com/collective/icalendar/issues/114 - """ - - directory = os.path.dirname(__file__) - ics = open(os.path.join(directory, 'issue_114_invalid_line.ics'), 'rb') - with self.assertRaises(ValueError): - cal = icalendar.Calendar.from_ical(ics.read()) - cal # pep 8 - ics.close() - def test_issue_116(self): """Issue #116/#117 - How to add 'X-APPLE-STRUCTURED-LOCATION' """