Skip to content

Commit 6582272

Browse files
committed
fix issue 67: use epidata client in covidcast integration tests
1 parent 4b26579 commit 6582272

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

integrations/server/test_covidcast.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# first party
1212
from delphi_utils import Nans
1313
from delphi.epidata.acquisition.covidcast.test_utils import CovidcastBase, CovidcastTestRow
14+
from delphi.epidata.client.delphi_epidata import Epidata
1415

1516
# use the local instance of the Epidata API
1617
BASE_URL = 'http://delphi_web_epidata/epidata/api.php'
@@ -22,11 +23,10 @@ def localSetUp(self):
2223
"""Perform per-test setup."""
2324
self._db._cursor.execute('update covidcast_meta_cache set timestamp = 0, epidata = "[]"')
2425

25-
def request_based_on_row(self, row: CovidcastTestRow, extract_response: Callable = lambda x: x.json(), **kwargs):
26+
def request_based_on_row(self, row: CovidcastTestRow, **kwargs):
2627
params = self.params_from_row(row, endpoint='covidcast', **kwargs)
27-
response = requests.get(BASE_URL, params=params)
28-
response.raise_for_status()
29-
response = extract_response(response)
28+
Epidata.BASE_URL = BASE_URL
29+
response = Epidata.covidcast(**params)
3030

3131
return response
3232

@@ -155,7 +155,6 @@ def test_csv_format(self):
155155
# NB 'format' is a Python reserved word
156156
response = self.request_based_on_row(
157157
row,
158-
extract_response=lambda resp: resp.text,
159158
**{'format':'csv'}
160159
)
161160

@@ -194,7 +193,7 @@ def test_fields(self):
194193
row = self._insert_placeholder_set_one()
195194

196195
# limit fields
197-
response = self.request_based_on_row(row, fields='time_value,geo_value')
196+
response = self.request_based_on_row(row, **{"fields":"time_value,geo_value"})
198197

199198
expected = row.as_api_compatibility_row_dict()
200199
expected_all = {

0 commit comments

Comments
 (0)