Skip to content

Commit 0aea6a8

Browse files
committed
test: add secrets, convert dfs
1 parent 3adce47 commit 0aea6a8

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

tests/test_epidata_calls.py

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,55 @@
66
# - it has access to the private endpoints being tested
77

88
auth = os.environ.get("DELPHI_EPIDATA_KEY")
9+
secret_cdc = os.environ.get("SECRET_API_AUTH_CDC")
10+
secret_fluview = os.environ.get("SECRET_API_AUTH_FLUVIEW")
11+
secret_ght = os.environ.get("SECRET_API_AUTH_GHT")
12+
secret_norostat = os.environ.get("SECRET_API_AUTH_NOROSTAT")
13+
secret_quidel = os.environ.get("SECRET_API_AUTH_QUIDEL")
14+
secret_sensors = os.environ.get("SECRET_API_AUTH_SENSORS")
15+
secret_twitter = os.environ.get("SECRET_API_AUTH_TWITTER")
916

1017
def test_pvt_cdc() -> None:
1118
apicall = Epidata.pvt_cdc(
12-
auth = auth,
19+
auth = secret_cdc,
1320
locations = "fl,ca",
1421
epiweeks = EpiRange(201501, 201601)
1522
)
16-
data = apicall.json()
23+
data = apicall.df()
1724
assert(len(data) > 0)
1825

1926
def test_pub_covid_hosp_facility_lookup() -> None:
2027
apicall = Epidata.pub_covid_hosp_facility_lookup(state="fl")
21-
data = apicall.json()
28+
data = apicall.df()
2229
assert(len(data) > 0)
2330

2431
apicall = Epidata.pub_covid_hosp_facility_lookup(city="southlake")
25-
data = apicall.json()
32+
data = apicall.df()
2633
assert(len(data) > 0)
2734

2835
def test_pub_covid_hosp_facility() -> None:
2936
apicall = Epidata.pub_covid_hosp_facility(
3037
hospital_pks = "100075",
3138
collection_weeks = EpiRange(20200101, 20200501))
32-
data = apicall.json()
39+
data = apicall.df()
3340
assert(len(data) > 0)
3441

3542
apicall = Epidata.pub_covid_hosp_facility(
3643
hospital_pks = "100075",
3744
collection_weeks = EpiRange(202001, 202005))
38-
data = apicall.json()
45+
data = apicall.df()
3946
assert(len(data) > 0) # fails
4047

4148
def test_pub_covid_hosp_state_timeseries() -> None:
4249
apicall = Epidata.pub_covid_hosp_state_timeseries(
4350
states = "fl",
4451
dates = EpiRange(20200101, 20200501))
45-
data = apicall.json()
52+
data = apicall.df()
4653
assert(len(data) > 0)
4754

4855
def test_pub_covidcast_meta() -> None:
4956
apicall = Epidata.pub_covidcast_meta()
50-
data = apicall.json()
57+
data = apicall.df()
5158
assert(len(data) > 0)
5259

5360
def test_pub_covidcast() -> None:
@@ -58,7 +65,7 @@ def test_pub_covidcast() -> None:
5865
time_type = "day",
5966
geo_values = ["ca", "fl"],
6067
time_values = EpiRange(20200601, 20200801))
61-
data = apicall.json()
68+
data = apicall.df()
6269
assert(len(data) > 0)
6370

6471
apicall = Epidata.pub_covidcast(
@@ -68,7 +75,7 @@ def test_pub_covidcast() -> None:
6875
time_type = "day",
6976
geo_values = "*",
7077
time_values = EpiRange(20200601, 20200801))
71-
data = apicall.json()
78+
data = apicall.df()
7279
assert(len(data) > 0)
7380

7481
def test_pub_delphi() -> None:
@@ -84,17 +91,17 @@ def test_pub_dengue_nowcast() -> None:
8491
locations = "pr",
8592
epiweeks = EpiRange(201401, 202301)
8693
)
87-
data = apicall.json()
94+
data = apicall.df()
8895
assert(len(data) > 0)
8996

9097
def test_pvt_dengue_sensors() -> None:
9198
apicall = Epidata.pvt_dengue_sensors(
92-
auth = auth,
99+
auth = secret_norostat,
93100
names = "ght",
94101
locations = "ag",
95102
epiweeks = EpiRange(201501, 202001)
96103
)
97-
data = apicall.json()
104+
data = apicall.df()
98105
assert(len(data) > 0)
99106

100107
def test_pub_ecdc_ili() -> None:
@@ -139,17 +146,17 @@ def test_pub_gft() -> None:
139146
locations = "hhs1",
140147
epiweeks = EpiRange(201201, 202001)
141148
)
142-
data = apicall.json()
149+
data = apicall.df()
143150
assert(len(data) > 0)
144151

145152
def test_pvt_ght() -> None:
146153
apicall = Epidata.pvt_ght(
147-
auth = auth,
154+
auth = secret_ght,
148155
locations = "ma",
149156
epiweeks = EpiRange(199301, 202304),
150157
query = "how to get over the flu"
151158
)
152-
data = apicall.json()
159+
data = apicall.df()
153160
assert(len(data) > 0)
154161

155162
def test_pub_kcdc_ili() -> None:
@@ -162,7 +169,7 @@ def test_pub_kcdc_ili() -> None:
162169

163170
def test_pvt_meta_norostat() -> None:
164171
apicall = Epidata.pvt_meta_norostat(
165-
auth = auth
172+
auth = secret_norostat
166173
)
167174
data = apicall.classic()
168175
assert(len(data) > 0)
@@ -177,7 +184,7 @@ def test_pub_nidss_dengue() -> None:
177184
locations = "taipei",
178185
epiweeks = EpiRange(201201, 201301)
179186
)
180-
data = apicall.json()
187+
data = apicall.df()
181188
assert(len(data) > 0)
182189

183190
def test_pub_nidss_flu() -> None:
@@ -190,19 +197,20 @@ def test_pub_nidss_flu() -> None:
190197

191198
def test_pvt_norostat() -> None:
192199
apicall = Epidata.pvt_norostat(
193-
auth = auth,
200+
auth = secret_norostat,
194201
location = "1",
195202
epiweeks = 201233
196203
)
197-
data = apicall.json()
198-
assert(len(data) > 0)
204+
data = apicall.df()
205+
# TODO: Norostat is known to not return data
206+
# assert(len(data) > 0)
199207

200208
def test_pub_nowcast() -> None:
201209
apicall = Epidata.pub_nowcast(
202210
locations = "ca",
203211
epiweeks = EpiRange(201201, 201301)
204212
)
205-
data = apicall.json()
213+
data = apicall.df()
206214
assert(len(data) > 0)
207215

208216
def test_pub_paho_dengue() -> None:
@@ -215,31 +223,31 @@ def test_pub_paho_dengue() -> None:
215223

216224
def test_pvt_quidel() -> None:
217225
apicall = Epidata.pvt_quidel(
218-
auth = auth,
226+
auth = secret_quidel,
219227
locations = "hhs1",
220228
epiweeks = EpiRange(201201, 202001)
221229
)
222-
data = apicall.json()
230+
data = apicall.df()
223231
assert(len(data) > 0)
224232

225233
def test_pvt_sensors() -> None:
226234
apicall = Epidata.pvt_sensors(
227-
auth = auth,
235+
auth = secret_sensors,
228236
names = "sar3",
229237
locations = "nat",
230238
epiweeks = EpiRange(201501, 202001)
231239
)
232-
data = apicall.json()
240+
data = apicall.df()
233241
assert(len(data) > 0)
234242

235243
def test_pvt_twitter() -> None:
236244
apicall = Epidata.pvt_twitter(
237-
auth = auth,
245+
auth = secret_twitter,
238246
locations = "CA",
239247
time_type = "week",
240248
time_values = EpiRange(201501, 202001)
241249
)
242-
data = apicall.json()
250+
data = apicall.df()
243251
assert(len(data) > 0)
244252

245253
def test_pub_wiki() -> None:
@@ -248,5 +256,5 @@ def test_pub_wiki() -> None:
248256
time_type = "week",
249257
time_values = EpiRange(201501, 201601)
250258
)
251-
data = apicall.json()
259+
data = apicall.df()
252260
assert(len(data) > 0)

0 commit comments

Comments
 (0)