Skip to content

Commit

Permalink
✅ unittest for parse val history
Browse files Browse the repository at this point in the history
  • Loading branch information
codedawi committed May 20, 2020
1 parent 4106b7c commit 761f62d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_jhu.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,19 @@ async def test_get_locations(mock_client_session):
# `jhu.get_locations()` creates id based on recovered list
location_recovered = await jhu.get_category("recovered")
assert len(output) == len(location_recovered["locations"])


@pytest.mark.parametrize(
"key, locations, index, expected",
[
(("Thailand", "TH"), [{"country": "Thailand", "province": "TH", "history": {"test": "yes"}}], 0, {"test": "yes"}), # Success
(("Deutschland", "DE"), [{"country": "Deutschland", "province": "DE", "history": {"test": "no"}}], 1, {}), # IndexError
(("US", "NJ"), [{"country": "Deutschland", "province": "DE", "history": {"test": "no"}}], 0, {}), # Invaid Key Merge
],
)
def test_parse_history(key, locations, index, expected):
"""
Test validating and extracting history content from
locations data based on index.
"""
assert jhu.parse_history(key, locations, index) == expected

0 comments on commit 761f62d

Please sign in to comment.