Skip to content

Commit 3bfc94e

Browse files
committed
Update test_csbs to handle asyncio
1 parent 0e11daa commit 3bfc94e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed
File renamed without changes.

tests/test_csbs.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import app
77
from app.services.location import csbs
8+
from tests.fixtures import mock_client_session
9+
from tests.fixtures import mocked_session_get
810

911

1012
def mocked_csbs_requests_get(*args, **kwargs):
@@ -21,17 +23,20 @@ def read_file(self):
2123
"""
2224
Mock HTTP GET-method and return text from file
2325
"""
24-
filepath = "tests/example_data/sample_covid19_county.csv"
26+
filepath = "tests/example_data/covid19_county.csv"
2527
print("Try to read {}".format(filepath))
2628
with open(filepath, "r") as file:
2729
return file.read()
2830

2931
return FakeRequestsGetResponse()
3032

3133

32-
@mock.patch("app.services.location.csbs.requests.get", side_effect=mocked_csbs_requests_get)
33-
def test_get_locations(mock_request_get):
34-
data = csbs.get_locations()
34+
@pytest.mark.asyncio
35+
async def test_get_locations():
36+
async with mock_client_session() as mocked_client_session:
37+
mocked_client_session.get = mocked_session_get
38+
data = await csbs.get_locations()
39+
3540
assert isinstance(data, list)
3641

3742
# check to see that Unknown/Unassigned has been filtered

0 commit comments

Comments
 (0)