11
11
# first party
12
12
from delphi_utils import Nans
13
13
from delphi .epidata .acquisition .covidcast .test_utils import CovidcastBase , CovidcastTestRow
14
+ from delphi .epidata .client .delphi_epidata import Epidata
14
15
15
16
# use the local instance of the Epidata API
16
17
BASE_URL = 'http://delphi_web_epidata/epidata/api.php'
@@ -22,11 +23,10 @@ def localSetUp(self):
22
23
"""Perform per-test setup."""
23
24
self ._db ._cursor .execute ('update covidcast_meta_cache set timestamp = 0, epidata = "[]"' )
24
25
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 ):
26
27
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 )
30
30
31
31
return response
32
32
@@ -155,7 +155,6 @@ def test_csv_format(self):
155
155
# NB 'format' is a Python reserved word
156
156
response = self .request_based_on_row (
157
157
row ,
158
- extract_response = lambda resp : resp .text ,
159
158
** {'format' :'csv' }
160
159
)
161
160
@@ -194,7 +193,7 @@ def test_fields(self):
194
193
row = self ._insert_placeholder_set_one ()
195
194
196
195
# 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" } )
198
197
199
198
expected = row .as_api_compatibility_row_dict ()
200
199
expected_all = {
0 commit comments