forked from ExpDev07/coronavirus-tracker-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_timeline.py
More file actions
34 lines (28 loc) · 809 Bytes
/
test_timeline.py
File metadata and controls
34 lines (28 loc) · 809 Bytes
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
import pytest
from unittest import mock
from collections import OrderedDict
from app import timeline
def test_timeline_class():
# Unordered timeseries.
timeseries = {
'1/24/20': 5,
'1/22/20': 2,
'1/25/20': 7,
'1/23/20': 3,
}
history_data = timeline.Timeline(history=timeseries)
# validate last value
assert history_data.latest == 7
# validate order
assert list(dict(history_data.timeline).keys()) == ['1/22/20', '1/23/20', '1/24/20', '1/25/20']
# validate serialize
check_serialize = {
'latest': 7,
'timeline': OrderedDict([
('1/22/20', 2),
('1/23/20', 3),
('1/24/20', 5),
('1/25/20', 7),
])
}
assert dict(history_data.serialize()) == check_serialize