Skip to content

Commit 45dc4d4

Browse files
committed
add /latest test
1 parent 2854739 commit 45dc4d4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_routes.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from fastapi.testclient import TestClient
44
import json
55
from unittest import mock
6+
from pprint import pformat as pf
67
import pytest
78
from app import services
89
from app.main import APP
@@ -128,10 +129,34 @@ def tearDown(self):
128129
{"source": "jhu"},
129130
{"timelines": True},
130131
{"timelines": "true"},
132+
{"timelines": 1},
131133
{"source": "jhu", "timelines": True},
132134
],
133135
)
134136
def test_locations_status_code(api_client, query_params):
135137
response = api_client.get("/v2/locations", params=query_params)
136138
print(f"GET {response.url}\n{response}")
137139
assert response.status_code == 200
140+
141+
142+
@pytest.mark.parametrize(
143+
"query_params",
144+
[
145+
{"source": "csbs"},
146+
{"source": "jhu"},
147+
{"timelines": True},
148+
{"timelines": "true"},
149+
{"timelines": 1},
150+
{"source": "jhu", "timelines": True},
151+
],
152+
)
153+
def test_latest(api_client, query_params):
154+
response = api_client.get("/v2/latest", params=query_params)
155+
print(f"GET {response.url}\n{response}")
156+
157+
response_json = response.json()
158+
print(f"\tjson:\n{pf(response_json)}")
159+
160+
assert response.status_code == 200
161+
assert response_json["latest"]["confirmed"]
162+
assert response_json["latest"]["deaths"]

0 commit comments

Comments
 (0)