def _doRoundtrip(caldata, jcaldata): cal1 = Calendar.parseText(caldata) test1 = cal1.getText() cal2 = Calendar.parseJSONData(jcaldata) test2 = cal2.getText() self.assertEqual( test1, test2, "\n".join( difflib.unified_diff( str(test1).splitlines(), test2.splitlines())))
def _doRoundtrip(caldata, jcaldata): cal1 = Calendar.parseText(caldata) test1 = cal1.getText() cal2 = Calendar.parseJSONData(jcaldata) test2 = cal2.getText() self.assertEqual( test1, test2, "\n".join(difflib.unified_diff(str(test1).splitlines(), test2.splitlines())) )
def testjCalExample1(self): jcaldata = """["vcalendar", [ ["calscale", {}, "text", "GREGORIAN"], ["prodid", {}, "text", "-//Example Inc.//Example Calendar//EN"], ["version", {}, "text", "2.0"] ], [ ["vevent", [ ["dtstamp", {}, "date-time", "2008-02-05T19:12:24Z"], ["dtstart", {}, "date", "2008-10-06"], ["summary", {}, "text", "Planning meeting"], ["uid", {}, "text", "4088E990AD89CB3DBB484909"] ], [] ] ] ] """ icaldata = """BEGIN:VCALENDAR CALSCALE:GREGORIAN PRODID:-//Example Inc.//Example Calendar//EN VERSION:2.0 BEGIN:VEVENT DTSTAMP:20080205T191224Z DTSTART;VALUE=DATE:20081006 SUMMARY:Planning meeting UID:4088E990AD89CB3DBB484909 END:VEVENT END:VCALENDAR """.replace("\n", "\r\n") cal1 = Calendar.parseText(icaldata) test1 = cal1.getText() cal2 = Calendar.parseJSONData(jcaldata) test2 = cal2.getText() self.assertEqual( test1, test2, "\n".join(difflib.unified_diff(str(test1).splitlines(), test2.splitlines())) )
def testjCalExample1(self): jcaldata = """["vcalendar", [ ["calscale", {}, "text", "GREGORIAN"], ["prodid", {}, "text", "-//Example Inc.//Example Calendar//EN"], ["version", {}, "text", "2.0"] ], [ ["vevent", [ ["dtstamp", {}, "date-time", "2008-02-05T19:12:24Z"], ["dtstart", {}, "date", "2008-10-06"], ["summary", {}, "text", "Planning meeting"], ["uid", {}, "text", "4088E990AD89CB3DBB484909"] ], [] ] ] ] """ icaldata = """BEGIN:VCALENDAR CALSCALE:GREGORIAN PRODID:-//Example Inc.//Example Calendar//EN VERSION:2.0 BEGIN:VEVENT DTSTAMP:20080205T191224Z DTSTART;VALUE=DATE:20081006 SUMMARY:Planning meeting UID:4088E990AD89CB3DBB484909 END:VEVENT END:VCALENDAR """.replace("\n", "\r\n") cal1 = Calendar.parseText(icaldata) test1 = cal1.getText() cal2 = Calendar.parseJSONData(jcaldata) test2 = cal2.getText() self.assertEqual( test1, test2, "\n".join( difflib.unified_diff( str(test1).splitlines(), test2.splitlines())))
def testjCalExample2(self): jcaldata = """["vcalendar", [ ["prodid", {}, "text", "-//Example Corp.//Example Client//EN"], ["version", {}, "text", "2.0"] ], [ ["vtimezone", [ ["last-modified", {}, "date-time", "2004-01-10T03:28:45Z"], ["tzid", {}, "text", "US/Eastern"] ], [ ["daylight", [ ["dtstart", {}, "date-time", "2000-04-04T02:00:00"], ["rrule", {}, "recur", { "freq": "YEARLY", "byday": "1SU", "bymonth": 4 } ], ["tzname", {}, "text", "EDT"], ["tzoffsetfrom", {}, "utc-offset", "-05:00"], ["tzoffsetto", {}, "utc-offset", "-04:00"] ], [] ], ["standard", [ ["dtstart", {}, "date-time", "2000-10-26T02:00:00"], ["rrule", {}, "recur", { "freq": "YEARLY", "byday": "-1SU", "bymonth": 10 } ], ["tzname", {}, "text", "EST"], ["tzoffsetfrom", {}, "utc-offset", "-04:00:00"], ["tzoffsetto", {}, "utc-offset", "-05:00:00"] ], [] ] ] ], ["vevent", [ ["dtstamp", {}, "date-time", "2006-02-06T00:11:21Z"], ["dtstart", { "tzid": "US/Eastern" }, "date-time", "2006-01-02T12:00:00" ], ["duration", {}, "duration", "PT1H"], ["rrule", {}, "recur", { "freq": "DAILY", "count": 5 } ], ["rdate", { "tzid": "US/Eastern" }, "period", ["2006-01-02T15:00:00", "PT2H"] ], ["summary", {}, "text", "Event #2"], ["description", {}, "text", "We are having a meeting all this week at 12 pm for one hour, with an additional meeting on the first day 2 hours long.\\nPlease bring your own lunch for the 12 pm meetings." ], ["uid", {}, "text", "*****@*****.**"] ], [] ], ["vevent", [ ["dtstamp", {}, "date-time", "2006-02-06T00:11:21Z"], ["dtstart", { "tzid": "US/Eastern" }, "date-time", "2006-01-04T14:00:00" ], ["duration", {}, "duration", "PT1H"], ["recurrence-id", { "tzid": "US/Eastern" }, "date-time", "2006-01-04T12:00:00" ], ["summary", {}, "text", "Event #2 bis"], ["uid", {}, "text", "*****@*****.**"] ], [] ] ] ] """ icaldata = """BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Example Corp.//Example Client//EN BEGIN:VTIMEZONE LAST-MODIFIED:20040110T032845Z TZID:US/Eastern BEGIN:DAYLIGHT DTSTART:20000404T020000 RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 TZNAME:EDT TZOFFSETFROM:-0500 TZOFFSETTO:-0400 END:DAYLIGHT BEGIN:STANDARD DTSTART:20001026T020000 RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 TZNAME:EST TZOFFSETFROM:-0400 TZOFFSETTO:-0500 END:STANDARD END:VTIMEZONE BEGIN:VEVENT DTSTAMP:20060206T001121Z DTSTART;TZID=US/Eastern:20060102T120000 DURATION:PT1H RRULE:FREQ=DAILY;COUNT=5 RDATE;TZID=US/Eastern;VALUE=PERIOD:20060102T150000/PT2H SUMMARY:Event #2 DESCRIPTION:We are having a meeting all this week at 12 pm fo r one hour\\, with an additional meeting on the first day 2 h ours long.\\nPlease bring your own lunch for the 12 pm meetin gs. UID:[email protected] END:VEVENT BEGIN:VEVENT DTSTAMP:20060206T001121Z DTSTART;TZID=US/Eastern:20060104T140000 DURATION:PT1H RECURRENCE-ID;TZID=US/Eastern:20060104T120000 SUMMARY:Event #2 bis UID:[email protected] END:VEVENT END:VCALENDAR """.replace("\n", "\r\n") cal1 = Calendar.parseText(icaldata) test1 = cal1.getText() cal2 = Calendar.parseJSONData(jcaldata) test2 = cal2.getText() self.assertEqual( test1, test2, "\n".join(difflib.unified_diff(str(test1).splitlines(), test2.splitlines())) )
def testjCalExample2(self): jcaldata = """["vcalendar", [ ["prodid", {}, "text", "-//Example Corp.//Example Client//EN"], ["version", {}, "text", "2.0"] ], [ ["vtimezone", [ ["last-modified", {}, "date-time", "2004-01-10T03:28:45Z"], ["tzid", {}, "text", "US/Eastern"] ], [ ["daylight", [ ["dtstart", {}, "date-time", "2000-04-04T02:00:00"], ["rrule", {}, "recur", { "freq": "YEARLY", "byday": "1SU", "bymonth": 4 } ], ["tzname", {}, "text", "EDT"], ["tzoffsetfrom", {}, "utc-offset", "-05:00"], ["tzoffsetto", {}, "utc-offset", "-04:00"] ], [] ], ["standard", [ ["dtstart", {}, "date-time", "2000-10-26T02:00:00"], ["rrule", {}, "recur", { "freq": "YEARLY", "byday": "-1SU", "bymonth": 10 } ], ["tzname", {}, "text", "EST"], ["tzoffsetfrom", {}, "utc-offset", "-04:00:00"], ["tzoffsetto", {}, "utc-offset", "-05:00:00"] ], [] ] ] ], ["vevent", [ ["dtstamp", {}, "date-time", "2006-02-06T00:11:21Z"], ["dtstart", { "tzid": "US/Eastern" }, "date-time", "2006-01-02T12:00:00" ], ["duration", {}, "duration", "PT1H"], ["rrule", {}, "recur", { "freq": "DAILY", "count": 5 } ], ["rdate", { "tzid": "US/Eastern" }, "period", ["2006-01-02T15:00:00", "PT2H"] ], ["summary", {}, "text", "Event #2"], ["description", {}, "text", "We are having a meeting all this week at 12 pm for one hour, with an additional meeting on the first day 2 hours long.\\nPlease bring your own lunch for the 12 pm meetings." ], ["uid", {}, "text", "*****@*****.**"] ], [] ], ["vevent", [ ["dtstamp", {}, "date-time", "2006-02-06T00:11:21Z"], ["dtstart", { "tzid": "US/Eastern" }, "date-time", "2006-01-04T14:00:00" ], ["duration", {}, "duration", "PT1H"], ["recurrence-id", { "tzid": "US/Eastern" }, "date-time", "2006-01-04T12:00:00" ], ["summary", {}, "text", "Event #2 bis"], ["uid", {}, "text", "*****@*****.**"] ], [] ] ] ] """ icaldata = """BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Example Corp.//Example Client//EN BEGIN:VTIMEZONE LAST-MODIFIED:20040110T032845Z TZID:US/Eastern BEGIN:DAYLIGHT DTSTART:20000404T020000 RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4 TZNAME:EDT TZOFFSETFROM:-0500 TZOFFSETTO:-0400 END:DAYLIGHT BEGIN:STANDARD DTSTART:20001026T020000 RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10 TZNAME:EST TZOFFSETFROM:-0400 TZOFFSETTO:-0500 END:STANDARD END:VTIMEZONE BEGIN:VEVENT DTSTAMP:20060206T001121Z DTSTART;TZID=US/Eastern:20060102T120000 DURATION:PT1H RRULE:FREQ=DAILY;COUNT=5 RDATE;TZID=US/Eastern;VALUE=PERIOD:20060102T150000/PT2H SUMMARY:Event #2 DESCRIPTION:We are having a meeting all this week at 12 pm fo r one hour\\, with an additional meeting on the first day 2 h ours long.\\nPlease bring your own lunch for the 12 pm meetin gs. UID:[email protected] END:VEVENT BEGIN:VEVENT DTSTAMP:20060206T001121Z DTSTART;TZID=US/Eastern:20060104T140000 DURATION:PT1H RECURRENCE-ID;TZID=US/Eastern:20060104T120000 SUMMARY:Event #2 bis UID:[email protected] END:VEVENT END:VCALENDAR """.replace("\n", "\r\n") cal1 = Calendar.parseText(icaldata) test1 = cal1.getText() cal2 = Calendar.parseJSONData(jcaldata) test2 = cal2.getText() self.assertEqual( test1, test2, "\n".join( difflib.unified_diff( str(test1).splitlines(), test2.splitlines())))