def test_event_rrule_this_and_future_allday_prior(): event_rrule_this_and_future_allday_prior = \ event_rrule_this_and_future_allday_temp.format(20140705, 20140706) dbi = backend.SQLiteDb('home', ':memory:', locale=locale) dbi.update(event_rrule_this_and_future_allday_prior, href='rrule_this_and_future_allday.ics', etag='abcd') assert dbi.list() == [('rrule_this_and_future_allday.ics', 'abcd')] events = get_allday_range(dbi, date(2014, 4, 30), date(2014, 9, 26)) assert len(events) == 6 assert events[0].start == date(2014, 6, 30) assert events[1].start == date(2014, 7, 5) assert events[2].start == date(2014, 7, 12) assert events[3].start == date(2014, 7, 19) assert events[4].start == date(2014, 7, 26) assert events[5].start == date(2014, 8, 2) assert events[0].end == date(2014, 7, 1) assert events[1].end == date(2014, 7, 6) assert events[2].end == date(2014, 7, 13) assert events[3].end == date(2014, 7, 20) assert events[4].end == date(2014, 7, 27) assert events[5].end == date(2014, 8, 3) assert unicode_type(events[0].vevent['SUMMARY']) == u'Arbeit' for event in events[1:]: assert unicode_type(event.vevent['SUMMARY']) == u'Arbeit (lang)'
def test_event_rrule_multi_this_and_future_allday(): dbi = backend.SQLiteDb('home', ':memory:', locale=locale) dbi.update(event_rrule_multi_this_and_future_allday, href='event_rrule_multi_this_and_future_allday.ics', etag='abcd') assert dbi.list() == [('event_rrule_multi_this_and_future_allday.ics', 'abcd')] events = get_allday_range(dbi, start=date(2014, 4, 30), end=date(2014, 9, 26)) # we are getting two events twice, because they last for two days assert len(events) == 8 assert events[0].start == date(2014, 6, 30) assert events[1].start == date(2014, 7, 12) assert events[2].start == date(2014, 7, 12) assert events[3].start == date(2014, 7, 17) assert events[4].start == date(2014, 7, 19) assert events[5].start == date(2014, 7, 19) assert events[6].start == date(2014, 7, 24) assert events[7].start == date(2014, 7, 31) assert events[0].end == date(2014, 7, 1) assert events[1].end == date(2014, 7, 14) assert events[2].end == date(2014, 7, 14) assert events[3].end == date(2014, 7, 18) assert events[4].end == date(2014, 7, 21) assert events[5].end == date(2014, 7, 21) assert events[6].end == date(2014, 7, 25) assert events[7].end == date(2014, 8, 1) assert unicode_type(events[0].vevent['SUMMARY']) == u'Arbeit' for event in events[1:3] + events[4:6]: assert unicode_type(event.vevent['SUMMARY']) == u'Arbeit (lang)' for event in events[3:4] + events[6:]: assert unicode_type(event.vevent['SUMMARY']) == u'Arbeit (neu)'
def test_event_rrule_this_and_future_multi_day_shift(): dbi = backend.SQLiteDb('home', ':memory:', locale=locale) dbi.update(event_rrule_this_and_future_multi_day_shift, href='12345.ics', etag='abcd') assert dbi.list() == [('12345.ics', 'abcd')] events = dbi.get_time_range(datetime(2014, 4, 30, 0, 0), datetime(2014, 9, 26, 0, 0)) events = sorted(events, key=lambda x: x.start) assert len(events) == 6 assert events[0].start == berlin.localize(datetime(2014, 6, 30, 7, 0)) assert events[1].start == berlin.localize(datetime(2014, 7, 8, 9, 0)) assert events[2].start == berlin.localize(datetime(2014, 7, 15, 9, 0)) assert events[3].start == berlin.localize(datetime(2014, 7, 22, 9, 0)) assert events[4].start == berlin.localize(datetime(2014, 7, 29, 9, 0)) assert events[5].start == berlin.localize(datetime(2014, 8, 5, 9, 0)) assert events[0].end == berlin.localize(datetime(2014, 6, 30, 12, 0)) assert events[1].end == berlin.localize(datetime(2014, 7, 9, 15, 0)) assert events[2].end == berlin.localize(datetime(2014, 7, 16, 15, 0)) assert events[3].end == berlin.localize(datetime(2014, 7, 23, 15, 0)) assert events[4].end == berlin.localize(datetime(2014, 7, 30, 15, 0)) assert events[5].end == berlin.localize(datetime(2014, 8, 6, 15, 0)) assert unicode_type(events[0].vevent['SUMMARY']) == u'Arbeit' for event in events[1:]: assert unicode_type(event.vevent['SUMMARY']) == u'Arbeit (lang)'
def test_event_rrule_this_and_future_allday(): dbi = backend.SQLiteDb('home', ':memory:', locale=LOCALE_BERLIN) dbi.update(event_rrule_this_and_future_allday, href='rrule_this_and_future_allday.ics', etag='abcd') assert dbi.list() == [('rrule_this_and_future_allday.ics', 'abcd')] events = get_allday_range(dbi, date(2014, 4, 30), date(2014, 9, 26)) assert len(events) == 6 assert events[0].start == date(2014, 6, 30) assert events[1].start == date(2014, 7, 8) assert events[2].start == date(2014, 7, 15) assert events[3].start == date(2014, 7, 22) assert events[4].start == date(2014, 7, 29) assert events[5].start == date(2014, 8, 5) assert events[0].end == date(2014, 6, 30) assert events[1].end == date(2014, 7, 8) assert events[2].end == date(2014, 7, 15) assert events[3].end == date(2014, 7, 22) assert events[4].end == date(2014, 7, 29) assert events[5].end == date(2014, 8, 5) assert unicode_type(events[0].summary) == u'Arbeit' for event in events[1:]: assert unicode_type(event.summary) == u'Arbeit (lang)'
def test_event_rrule_this_and_future(): dbi = backend.SQLiteDb('home', ':memory:', locale=LOCALE_BERLIN) dbi.update(event_rrule_this_and_future, href='12345.ics', etag='abcd') assert dbi.list() == [('12345.ics', 'abcd')] events = dbi.get_time_range(datetime(2014, 4, 30, 0, 0), datetime(2014, 9, 26, 0, 0)) events = sorted(events, key=lambda x: x.start) assert len(events) == 6 assert events[0].start == BERLIN.localize(datetime(2014, 6, 30, 7, 0)) assert events[1].start == BERLIN.localize(datetime(2014, 7, 7, 9, 0)) assert events[2].start == BERLIN.localize(datetime(2014, 7, 14, 9, 0)) assert events[3].start == BERLIN.localize(datetime(2014, 7, 21, 9, 0)) assert events[4].start == BERLIN.localize(datetime(2014, 7, 28, 9, 0)) assert events[5].start == BERLIN.localize(datetime(2014, 8, 4, 9, 0)) assert events[0].end == BERLIN.localize(datetime(2014, 6, 30, 12, 0)) assert events[1].end == BERLIN.localize(datetime(2014, 7, 7, 18, 0)) assert events[2].end == BERLIN.localize(datetime(2014, 7, 14, 18, 0)) assert events[3].end == BERLIN.localize(datetime(2014, 7, 21, 18, 0)) assert events[4].end == BERLIN.localize(datetime(2014, 7, 28, 18, 0)) assert events[5].end == BERLIN.localize(datetime(2014, 8, 4, 18, 0)) assert unicode_type(events[0].summary) == u'Arbeit' for num, event in enumerate(events[1:]): event.raw assert unicode_type(event.summary) == u'Arbeit (lang)'
def test_event_rrule_multi_this_and_future_allday(): dbi = backend.SQLiteDb('home', ':memory:', locale=locale) dbi.update(event_rrule_multi_this_and_future_allday, href='event_rrule_multi_this_and_future_allday.ics', etag='abcd') assert dbi.list() == [('event_rrule_multi_this_and_future_allday.ics', 'abcd')] events = dbi.get_allday_range(start=date(2014, 4, 30), end=date(2014, 9, 26)) events = sorted(events, key=lambda x: x.start) assert len(events) == 6 assert events[0].start == date(2014, 6, 30) assert events[1].start == date(2014, 7, 12) assert events[2].start == date(2014, 7, 17) assert events[3].start == date(2014, 7, 19) assert events[4].start == date(2014, 7, 24) assert events[5].start == date(2014, 7, 31) assert events[0].end == date(2014, 7, 1) assert events[1].end == date(2014, 7, 14) assert events[2].end == date(2014, 7, 18) assert events[3].end == date(2014, 7, 21) assert events[4].end == date(2014, 7, 25) assert events[5].end == date(2014, 8, 1) assert unicode_type(events[0].vevent['SUMMARY']) == u'Arbeit' for event in [events[1], events[3]]: assert unicode_type(event.vevent['SUMMARY']) == u'Arbeit (lang)' for event in events[2:3] + events[4:]: assert unicode_type(event.vevent['SUMMARY']) == u'Arbeit (neu)'
def test_event_rrule_this_and_future_allday(): dbi = backend.SQLiteDb('home', ':memory:', locale=locale) dbi.update(event_rrule_this_and_future_allday, href='rrule_this_and_future_allday.ics', etag='abcd') assert dbi.list() == [('rrule_this_and_future_allday.ics', 'abcd')] events = dbi.get_allday_range(date(2014, 4, 30), date(2014, 9, 26)) events = sorted(events, key=lambda x: x.start) assert len(events) == 6 assert events[0].start == date(2014, 6, 30) assert events[1].start == date(2014, 7, 8) assert events[2].start == date(2014, 7, 15) assert events[3].start == date(2014, 7, 22) assert events[4].start == date(2014, 7, 29) assert events[5].start == date(2014, 8, 5) assert events[0].end == date(2014, 7, 1) assert events[1].end == date(2014, 7, 9) assert events[2].end == date(2014, 7, 16) assert events[3].end == date(2014, 7, 23) assert events[4].end == date(2014, 7, 30) assert events[5].end == date(2014, 8, 6) assert unicode_type(events[0].vevent['SUMMARY']) == u'Arbeit' for event in events[1:]: assert unicode_type(event.vevent['SUMMARY']) == u'Arbeit (lang)'
def test_birthdays_no_year(tmpdir): dbpath = str(tmpdir) + '/khal.db' db = backend.SQLiteDb_Birthdays('home', dbpath, locale=locale) assert list(db.get_allday_range(date(1971, 3, 11))) == list() db.update(card_no_year, 'unix.vcf') events = list(db.get_allday_range(date(1971, 3, 11))) assert len(events) == 1 assert unicode_type(events[0].vevent['SUMMARY']) == u'Unix\'s birthday'