forked from ExpDev07/coronavirus-tracker-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_jhu.py
More file actions
24 lines (17 loc) · 830 Bytes
/
test_jhu.py
File metadata and controls
24 lines (17 loc) · 830 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
from unittest import mock
import pytest
from app import location
from app.services.location import jhu
from tests.conftest import mocked_strptime_isoformat
DATETIME_STRING = "2020-03-17T10:23:22.505550"
@pytest.mark.asyncio
async def test_get_locations(mock_client_session):
with mock.patch("app.services.location.jhu.datetime") as mock_datetime:
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
output = await jhu.get_locations()
assert isinstance(output, list)
assert isinstance(output[0], location.Location)
# `jhu.get_locations()` creates id based on confirmed list
location_confirmed = await jhu.get_category("confirmed")
assert len(output) == len(location_confirmed["locations"])