1
0
mirror of https://github.com/b4tman/sync_ics2gcal synced 2024-10-31 18:56:54 +00:00

parametrize test_filter_events_by_date

This commit is contained in:
Dmitry Belyaev 2018-04-17 22:53:56 +03:00
parent c38a3afe00
commit 94edbf1849
Signed by: b4tman
GPG Key ID: 014E87EC54B77673

View File

@ -18,6 +18,7 @@ def sha1(string):
h.update(string)
return h.hexdigest()
def gen_events(start, stop, start_time, no_time=False):
if no_time:
start_time = datetime.date(
@ -56,12 +57,14 @@ def gen_events(start, stop, start_time, no_time=False):
result.append(event)
return result
def gen_list_to_compare(start, stop):
result = []
for i in range(start, stop):
result.append({'iCalUID': 'test{:06d}'.format(i)})
return result
def get_start_date(event):
event_start = event['start']
start_date = None
@ -78,6 +81,7 @@ def get_start_date(event):
return result
def test_compare():
part_len = 20
# [1..2n]
@ -107,7 +111,9 @@ def test_compare():
for item in to_upd_ok:
assert item in to_upd
def test_filter_events_by_date(no_time=False):
@pytest.mark.parametrize("no_time", [True, False], ids=['date', 'dateTime'])
def test_filter_events_by_date(no_time):
msk = timezone('Europe/Moscow')
now = utc.localize(datetime.datetime.utcnow())
msk_now = msk.normalize(now.astimezone(msk))
@ -145,8 +151,6 @@ def test_filter_events_by_date(no_time=False):
for event in events_past:
assert get_start_date(event) < date_cmp
def test_filter_events_by_date_no_time():
test_filter_events_by_date(no_time=True)
def test_filter_events_to_update():
msk = timezone('Europe/Moscow')