def test_invaliddates_thunderbird_monthly_bymonthday1(icaltomapi, mapitoical, message): ical = open(os.path.join(dir_path, 'issues/ZCP9771-2.ics'), 'rb').read() blob = assert_get_glob_from_ical(icaltomapi, message, ical, 1) message.SaveChanges(0) rs = getrecurrencestate(blob) assert rs.ulRecurFrequency == RS.RF_MONTHLY assert rs.ulPeriod == 1 assert rs.ulPatternType == 2 assert rs.ulEndType, RS.ET_NEVER assert rs.ulDayOfMonth == 22 assert rs.ulEndDate == 0x5AE980DF assert RS.RTimeToUnixTime(rs.ulStartDate) == 1337644800 # revert mapitoical.AddMessage(message, '', 0) method, mical = mapitoical.Finalize(icalmapi.M2IC_NO_VTIMEZONE) ma = mical.split(b'\r\n') assert method == b'PUBLISH' assert b'RRULE:FREQ=MONTHLY;BYMONTHDAY=22' in ma assert b'DTSTART;TZID=Europe/Amsterdam:20120522T170000' in ma assert b'DTEND;TZID=Europe/Amsterdam:20120522T180000' in ma
def test_invaliddates_thunderbird_monthly_bymonthday_31th( icaltomapi, mapitoical, message): # outlook will show the item every month on the last day, caldav every month with 31 days # This is a issue? ical = open(os.path.join(dir_path, 'issues/ZCP9771-4.ics'), 'rb').read() blob = assert_get_glob_from_ical(icaltomapi, message, ical, 1) rs = getrecurrencestate(blob) assert rs.ulRecurFrequency == RS.RF_MONTHLY assert rs.ulPeriod == 1 assert rs.ulPatternType == 2 assert rs.ulEndType == RS.ET_NEVER assert rs.ulDayOfMonth == 31 assert RS.RTimeToUnixTime(rs.ulStartDate) == 1335744000 assert rs.ulEndDate == 0x5AE980DF # revert mapitoical.AddMessage(message, '', 0) method, mical = mapitoical.Finalize(icalmapi.M2IC_NO_VTIMEZONE) ma = mical.split(b'\r\n') assert method == b'PUBLISH' assert b'RRULE:FREQ=MONTHLY;BYMONTHDAY=31' in ma assert b'DTSTART;TZID=Europe/Amsterdam:20120430T160000' in ma assert b'DTEND;TZID=Europe/Amsterdam:20120430T170000' in ma
def test_invaliddates_thunderbird_monthly_byday3(icaltomapi, mapitoical, message): ical = open(os.path.join(dir_path, 'issues/ZCP9771-7.ics'), 'rb').read() blob = assert_get_glob_from_ical(icaltomapi, message, ical, 1) message.SaveChanges(0) rs = getrecurrencestate(blob) assert rs.ulRecurFrequency == RS.RF_MONTHLY assert rs.ulPeriod == 1 assert rs.ulPatternType == 3 assert rs.ulWeekNumber == 4 assert rs.ulEndType == RS.ET_NUMBER assert RS.RTimeToUnixTime(rs.ulStartDate) == 1337817600 assert RS.RTimeToUnixTime(rs.ulEndDate) == 1343260800 # revert mapitoical.AddMessage(message, '', 0) method, mical = mapitoical.Finalize(icalmapi.M2IC_NO_VTIMEZONE) ma = mical.split(b'\r\n') assert method == b'PUBLISH' assert b'RRULE:FREQ=MONTHLY;COUNT=3;BYDAY=4TH' in ma assert b'DTSTART;TZID=Europe/Amsterdam:20120524T200000' in ma assert b'DTEND;TZID=Europe/Amsterdam:20120524T210000' in ma
def test_daily(icaltomapi, mapitoical, message): ical = open(os.path.join(dir_path, 'ics/daily.ics'), 'rb').read() blob = assert_get_glob_from_ical(icaltomapi, message, ical, 1) rs = getrecurrencestate(blob) assert rs.ulRecurFrequency == RS.RF_DAILY assert rs.ulPeriod == 60*24 assert rs.ulPatternType == 0 assert rs.ulEndType == RS.ET_NEVER assert RS.RTimeToUnixTime(rs.ulStartDate) == 1327622400 # @todo, less hard-coded? start_of_day(DTSTART) assert rs.ulEndDate == 0x5AE980DF # revert mapitoical.AddMessage(message, '', 0) method, mical = mapitoical.Finalize(icalmapi.M2IC_NO_VTIMEZONE) ma = mical.split(b'\r\n') assert method == b'PUBLISH' assert b'RRULE:FREQ=DAILY' in ma assert b'DTSTART;TZID=Europe/Amsterdam:20120127T143000' in ma assert b'DTEND;TZID=Europe/Amsterdam:20120127T150000' in ma
def test_invaliddates_thunderbird_yearly_byday_bymonth6(icaltomapi, mapitoical, message): ical = open(os.path.join(dir_path, 'issues/ZCP9771-17.ics'), 'rb').read() blob = assert_get_glob_from_ical(icaltomapi, message, ical, 1) message.SaveChanges(0) rs = getrecurrencestate(blob) assert rs.ulRecurFrequency == RS.RF_YEARLY assert rs.ulPeriod == 12 assert rs.ulPatternType == 3 assert rs.ulEndType == RS.ET_NEVER assert RS.RTimeToUnixTime(rs.ulStartDate) == 1369785600 assert rs.ulEndDate == 0x5AE980DF # revert mapitoical.AddMessage(message, '', 0) method, mical = mapitoical.Finalize(icalmapi.M2IC_NO_VTIMEZONE) ma = mical.split(b'\r\n') assert method == b'PUBLISH' assert b'RRULE:FREQ=YEARLY;BYDAY=-1WE;BYMONTH=5' in ma assert b'DTSTART;TZID=Europe/Amsterdam:20130529T150000' in ma assert b'DTEND;TZID=Europe/Amsterdam:20130529T160000' in ma
def test_monthly_bysetpos_byday(icaltomapi, mapitoical, message): ical = open(os.path.join(dir_path, 'issues/ZCP10916.ics'), 'rb').read() blob = assert_get_glob_from_ical(icaltomapi, message, ical, 1) message.SaveChanges(0) rs = getrecurrencestate(blob) assert rs.ulRecurFrequency == RS.RF_MONTHLY assert rs.ulPeriod == 1 assert rs.ulPatternType == 3 assert rs.ulWeekNumber == 1 assert rs.ulEndType, RS.ET_NEVER assert RS.RTimeToUnixTime(rs.ulStartDate) == 1338508800 assert rs.ulEndDate == 0x5AE980DF # revert mapitoical.AddMessage(message, '', 0) method, mical = mapitoical.Finalize(icalmapi.M2IC_NO_VTIMEZONE) ma = mical.split(b'\r\n') assert method == b'PUBLISH' assert b'RRULE:FREQ=MONTHLY;BYMONTHDAY=1' in ma assert b'DTSTART;TZID=Europe/Amsterdam:20120601T150000' in ma assert b'DTEND;TZID=Europe/Amsterdam:20120601T160000' in ma
def getrecurrencestate(blob): rs = RS.RecurrenceState() rs.ParseBlob(blob, 0) return rs