Skip to content

Commit 761f62d

Browse files
author
codedawi
committed
✅ unittest for parse val history
1 parent 4106b7c commit 761f62d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_jhu.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,19 @@ async def test_get_locations(mock_client_session):
3030
# `jhu.get_locations()` creates id based on recovered list
3131
location_recovered = await jhu.get_category("recovered")
3232
assert len(output) == len(location_recovered["locations"])
33+
34+
35+
@pytest.mark.parametrize(
36+
"key, locations, index, expected",
37+
[
38+
(("Thailand", "TH"), [{"country": "Thailand", "province": "TH", "history": {"test": "yes"}}], 0, {"test": "yes"}), # Success
39+
(("Deutschland", "DE"), [{"country": "Deutschland", "province": "DE", "history": {"test": "no"}}], 1, {}), # IndexError
40+
(("US", "NJ"), [{"country": "Deutschland", "province": "DE", "history": {"test": "no"}}], 0, {}), # Invaid Key Merge
41+
],
42+
)
43+
def test_parse_history(key, locations, index, expected):
44+
"""
45+
Test validating and extracting history content from
46+
locations data based on index.
47+
"""
48+
assert jhu.parse_history(key, locations, index) == expected

0 commit comments

Comments
 (0)