forked from ExpDev07/coronavirus-tracker-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_csbs.py
More file actions
37 lines (27 loc) · 1011 Bytes
/
test_csbs.py
File metadata and controls
37 lines (27 loc) · 1011 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
import pytest
from app.services.location import csbs
def mocked_csbs_requests_get(*args, **kwargs):
class FakeRequestsGetResponse:
"""
Returns instance of `FakeRequestsGetResponse`
when calling `app.services.location.csbs.requests.get()
"""
def __init__(self):
self.text = self.read_file()
def read_file(self):
"""
Mock HTTP GET-method and return text from file
"""
filepath = "tests/example_data/covid19_county.csv"
print("Try to read {}".format(filepath))
with open(filepath, "r") as file:
return file.read()
return FakeRequestsGetResponse()
@pytest.mark.asyncio
async def test_get_locations(mock_client_session):
data = await csbs.get_locations()
assert isinstance(data, list)
# check to see that Unknown/Unassigned has been filtered
for d in data:
assert d.county != "Unknown"
assert d.county != "Unassigned"