1
0
mirror of https://github.com/b4tman/sync_ics2gcal synced 2025-01-21 07:28:24 +00:00

rewrite test_filter_events_no_updated

This commit is contained in:
Dmitry Belyaev 2022-02-22 09:52:28 +03:00
parent 89877bc6d8
commit b09136747f
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -180,27 +180,28 @@ def test_filter_events_to_update():
assert sync2.to_update == [] assert sync2.to_update == []
def test_filter_events_to_update_no_updated(): def test_filter_events_no_updated():
now = utc.localize(datetime.datetime.utcnow()) """
test filtering events that not have 'updated' field
one_hour = datetime.datetime( such events should always pass the filter
1, 1, 1, 2) - datetime.datetime(1, 1, 1, 1) """
date_upd = now + (one_hour * 5) now = datetime.datetime.utcnow()
yesterday = now - datetime.timedelta(days=-1)
count = 10 count = 10
events_old = gen_events(1, 1 + count, now) events_old = gen_events(1, 1 + count, now)
events_new = gen_events(1, 1 + count, date_upd) events_new = gen_events(1, 1 + count, now)
# 1/2 updated=yesterday, 1/2 no updated field
i = 0
for event in events_new: for event in events_new:
if 0 == i % 2:
event['updated'] = yesterday.isoformat() + 'Z'
else:
del event['updated'] del event['updated']
i += 1
sync1 = CalendarSync(None, None) sync = CalendarSync(None, None)
sync1.to_update = list(zip(events_new, events_old)) sync.to_update = list(zip(events_old, events_new))
sync1._filter_events_to_update() sync._filter_events_to_update()
assert len(sync.to_update) == count // 2
sync2 = CalendarSync(None, None)
sync2.to_update = list(zip(events_old, events_new))
sync2._filter_events_to_update()
assert len(sync1.to_update) == count
assert sync2.to_update == []