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
37 lines (28 loc) · 791 Bytes
/
test_timeline.py
File metadata and controls
37 lines (28 loc) · 791 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
35
36
37
from collections import OrderedDict
from unittest import mock
import pytest
from app import models
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 = models.Timeline(timeline=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