def test_success_conversion(store, icaltomapi, message): ical = open(os.path.join(dir_path, 'ics/success.ics'), 'rb').read() # As defined in namedprops.h DISPID_APPT_TS_REF = 0x25 NAMED_PROP_UID = MAPINAMEID(PSETID_Kopano_CalDav, MNID_ID, DISPID_APPT_TS_REF) NAMED_PROP_CATEGORY = MAPINAMEID(PS_PUBLIC_STRINGS, MNID_STRING, 'Keywords') properties = store.GetIDsFromNames([NAMED_PROP_UID, NAMED_PROP_CATEGORY], MAPI_CREATE) EXPECTED_MESSAGES = 1 UID = CHANGE_PROP_TYPE(properties[0], PT_BINARY) #0x85100102 CATEGORY = CHANGE_PROP_TYPE(properties[1], PT_MV_UNICODE) #0x850B101E START_DATE_PT_SYSTIME = 135547524000000000 END_DATE_PT_SYSTIME = 135547920000000000 prop_dic = { UID: [b'*****@*****.**'], PR_SUBJECT: [b'A dream holiday in the mountains'], CATEGORY: [['Holidays']], PR_SENDER_NAME_W: ['John Holidays'], PR_SENDER_EMAIL_ADDRESS_W: ['*****@*****.**'], PR_START_DATE: [FileTime(START_DATE_PT_SYSTIME)], PR_END_DATE: [FileTime(END_DATE_PT_SYSTIME)], } assert_item_count_from_ical(icaltomapi, ical, EXPECTED_MESSAGES) assert_properties_from_ical(icaltomapi, message, prop_dic)
def test_round_trip_all_day_dstart_dend_style_not_date_incorrect(store, icaltomapi, mapitoical, message): ical = open(os.path.join(dir_path, 'ics/allday_dstart_dend_style_incorrect.ics'), 'rb').read() # As defined in namedprops.h DISPID_ALL_DAY_EVENT = 0x8215 EXPECTED_MESSAGES = 1 START_DATE_PT_SYSTIME = 132587712000000000 END_DATE_PT_SYSTIME = 132588576000000000 ALL_DAY_NAMEID = MAPINAMEID(PSETID_Appointment, MNID_ID, DISPID_ALL_DAY_EVENT) ALL_DAY_PROP = CHANGE_PROP_TYPE( store.GetIDsFromNames([ALL_DAY_NAMEID], MAPI_CREATE)[0], PT_BOOLEAN ) prop_dic = { PR_START_DATE: [FileTime(START_DATE_PT_SYSTIME)], PR_END_DATE: [FileTime(END_DATE_PT_SYSTIME)], ALL_DAY_PROP: [False] } assert_item_count_from_ical(icaltomapi, ical, EXPECTED_MESSAGES) assert_properties_from_ical(icaltomapi, message, prop_dic) # Reverting back to ical. mapitoical.AddMessage(message, '', 0) method, converted_ical = mapitoical.Finalize(icalmapi.M2IC_NO_VTIMEZONE) split_ical = converted_ical.split(b'\r\n') assert b'PUBLISH' == method assert b'DTSTART:20210226T000000Z' in split_ical assert b'DTEND:20210227T000000Z' in split_ical