-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_rink.py
64 lines (54 loc) · 2 KB
/
test_rink.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import pytest
import json
from dateutil.parser import parse as parse_date
from rinks import *
START = parse_date('2023-04-20').replace(tzinfo=PACIFIC)
END = parse_date('2023-04-21').replace(tzinfo=PACIFIC)
class FakeKirkland(Kirkland):
def _events(self):
with open('fixture_kirkland.json') as f:
return json.load(f)['data']
class FakeSnoqualmie(Snoqualmie):
def _events(self):
with open('fixture_snoqualmie.json') as f:
return json.load(f)['data']
class FakeRenton(Renton):
def _events(self):
with open('fixture_renton.json') as f:
return json.load(f)['data']
def test_event():
events = FakeKirkland(START, END).gcal('stick_n_puck')
events = list(events)
assert len(events) == 1
expected_event = Event(
"Kirkland Stick N Puck",
start=parse_date("2023-04-20 11:30:00"),
end=parse_date("2023-04-20 12:30:00"),
location="SnoKing Kirkland Rink")
assert events[0].summary == expected_event.summary
assert events[0].start == expected_event.start
assert events[0].end == expected_event.end
assert events[0].location == expected_event.location
assert events_are_same(events[0], expected_event)
def test_any_filter():
events = FakeKirkland(START, END).gcal('any')
events = list(events)
assert len(events) == 18
def test_combine_like_events():
events = FakeRenton(START, END).gcal('stick_n_puck')
events = list(events)
assert len(events) == 6
events = combine_like_events(events)
assert len(events) == 3
def test_new_events():
events = FakeKirkland(START, END).gcal('any')
events = list(events)
excluded_event = events[0]
existing_events = events[1:]
assert [excluded_event] == subtract_events(events, existing_events)
def test_delete_events():
events = FakeKirkland(START, END).gcal('any')
events = list(events)
excluded_event = events[0]
existing_events = events
assert [excluded_event] == subtract_events(existing_events, events[1:])