Skip to content

Commit 44aad75

Browse files
committed
test wildcard
1 parent fa4315e commit 44aad75

File tree

1 file changed

+177
-0
lines changed

1 file changed

+177
-0
lines changed

tests/testthat/test-endpoints.R

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,183 @@ test_that("basic_epidata_call", {
147147
) %>% request_url())
148148
})
149149

150+
test_that("endoints accept wildcard for date parameter", {
151+
expect_no_error(call <- pvt_cdc(
152+
auth = "yourkey",
153+
"fl,ca",
154+
"*",
155+
fetch_args = fetch_args_list(dry_run = TRUE)
156+
))
157+
expect_identical(call$params$epiweeks$from, 100001)
158+
expect_identical(call$params$epiweeks$to, 300001)
159+
160+
expect_identical(call$params$epiweeks$from, 100001)
161+
expect_identical(call$params$epiweeks$to, 300001)
162+
163+
expect_no_error(call <- pub_covid_hosp_facility(
164+
hospital_pks = "100075",
165+
collection_weeks = "*",
166+
fetch_args = fetch_args_list(dry_run = TRUE)
167+
))
168+
expect_identical(call$params$collection_weeks$from, 10000101)
169+
expect_identical(call$params$collection_weeks$to, 30000101)
170+
171+
expect_no_error(call <- pub_covid_hosp_state_timeseries(
172+
states = "fl",
173+
dates = "*",
174+
fetch_args = fetch_args_list(dry_run = TRUE)
175+
))
176+
expect_identical(call$params$dates$from, 10000101)
177+
expect_identical(call$params$dates$to, 30000101)
178+
179+
expect_no_error(call <- pub_covidcast(
180+
source = "jhu-csse",
181+
signals = "confirmed_7dav_incidence_prop",
182+
time_type = "day",
183+
geo_type = "state",
184+
time_values = "*",
185+
geo_values = "ca,fl",
186+
fetch_args = fetch_args_list(dry_run = TRUE)
187+
))
188+
expect_identical(call$params$time_values, "*")
189+
190+
expect_no_error(call <- pub_dengue_nowcast(
191+
locations = "ca",
192+
epiweeks = "*",
193+
fetch_args = fetch_args_list(dry_run = TRUE)
194+
))
195+
expect_identical(call$params$epiweeks$from, 100001)
196+
expect_identical(call$params$epiweeks$to, 300001)
197+
198+
expect_no_error(call <- pvt_dengue_sensors(
199+
auth = "yourkey",
200+
names = "ght",
201+
locations = "ag",
202+
epiweeks = "*",
203+
fetch_args = fetch_args_list(dry_run = TRUE)
204+
))
205+
expect_identical(call$params$epiweeks$from, 100001)
206+
expect_identical(call$params$epiweeks$to, 300001)
207+
208+
expect_no_error(call <- pub_ecdc_ili(
209+
regions = "austria",
210+
epiweeks = "*",
211+
fetch_args = fetch_args_list(dry_run = TRUE)
212+
))
213+
expect_identical(call$params$epiweeks$from, 100001)
214+
expect_identical(call$params$epiweeks$to, 300001)
215+
216+
expect_no_error(call <- pub_flusurv(
217+
locations = "CA",
218+
epiweeks = "*",
219+
fetch_args = fetch_args_list(dry_run = TRUE)
220+
))
221+
expect_identical(call$params$epiweeks$from, 100001)
222+
expect_identical(call$params$epiweeks$to, 300001)
223+
224+
expect_no_error(call <- pub_fluview_clinical(
225+
regions = "nat",
226+
epiweeks = "*",
227+
fetch_args = fetch_args_list(dry_run = TRUE)
228+
))
229+
expect_identical(call$params$epiweeks$from, 100001)
230+
expect_identical(call$params$epiweeks$to, 300001)
231+
232+
expect_no_error(call <- pub_fluview(
233+
regions = "nat",
234+
epiweeks = "*",
235+
fetch_args = fetch_args_list(dry_run = TRUE)
236+
))
237+
expect_identical(call$params$epiweeks$from, 100001)
238+
expect_identical(call$params$epiweeks$to, 300001)
239+
240+
expect_no_error(call <- pub_gft(
241+
locations = "hhs1",
242+
epiweeks = "*",
243+
fetch_args = fetch_args_list(dry_run = TRUE)
244+
))
245+
expect_identical(call$params$epiweeks$from, 100001)
246+
expect_identical(call$params$epiweeks$to, 300001)
247+
248+
expect_no_error(call <- pvt_ght(
249+
auth = "yourkey",
250+
locations = "ca",
251+
epiweeks = "*",
252+
query = "how to get over the flu",
253+
fetch_args = fetch_args_list(dry_run = TRUE)
254+
))
255+
expect_identical(call$params$epiweeks$from, 100001)
256+
expect_identical(call$params$epiweeks$to, 300001)
257+
258+
expect_no_error(call <- pub_kcdc_ili(
259+
regions = "ROK",
260+
epiweeks = "*",
261+
fetch_args = fetch_args_list(dry_run = TRUE)
262+
))
263+
expect_identical(call$params$epiweeks$from, 100001)
264+
expect_identical(call$params$epiweeks$to, 300001)
265+
266+
expect_no_error(call <- pub_nidss_dengue(
267+
locations = "taipei",
268+
epiweeks = "*",
269+
fetch_args = fetch_args_list(dry_run = TRUE)
270+
))
271+
expect_identical(call$params$epiweeks$from, 100001)
272+
expect_identical(call$params$epiweeks$to, 300001)
273+
274+
expect_no_error(call <- pub_nidss_flu(
275+
regions = "taipei",
276+
epiweeks = "*",
277+
fetch_args = fetch_args_list(dry_run = TRUE)
278+
))
279+
expect_identical(call$params$epiweeks$from, 100001)
280+
expect_identical(call$params$epiweeks$to, 300001)
281+
282+
expect_no_error(call <- pvt_norostat(
283+
auth = "yourkey",
284+
locations = "Minnesota, Ohio, Oregon, Tennessee, and Wisconsin",
285+
epiweeks = "*",
286+
fetch_args = fetch_args_list(dry_run = TRUE)
287+
))
288+
expect_identical(call$params$epiweeks$from, 100001)
289+
expect_identical(call$params$epiweeks$to, 300001)
290+
291+
expect_no_error(call <- pub_nowcast(
292+
locations = "ca",
293+
epiweeks = "*",
294+
fetch_args = fetch_args_list(dry_run = TRUE)
295+
))
296+
expect_identical(call$params$epiweeks$from, 100001)
297+
expect_identical(call$params$epiweeks$to, 300001)
298+
299+
expect_no_error(call <- pub_paho_dengue(
300+
regions = "ca",
301+
epiweeks = "*",
302+
fetch_args = fetch_args_list(dry_run = TRUE)
303+
))
304+
expect_identical(call$params$epiweeks$from, 100001)
305+
expect_identical(call$params$epiweeks$to, 300001)
306+
307+
expect_no_error(call <- pvt_quidel(
308+
auth = "yourkey",
309+
locations = "hhs1",
310+
epiweeks = "*",
311+
fetch_args = fetch_args_list(dry_run = TRUE)
312+
))
313+
expect_identical(call$params$epiweeks$from, 100001)
314+
expect_identical(call$params$epiweeks$to, 300001)
315+
316+
expect_no_error(call <- pvt_sensors(
317+
auth = "yourkey",
318+
names = "sar3",
319+
locations = "nat",
320+
epiweeks = "*",
321+
fetch_args = fetch_args_list(dry_run = TRUE)
322+
))
323+
expect_identical(call$params$epiweeks$from, 100001)
324+
expect_identical(call$params$epiweeks$to, 300001)
325+
})
326+
150327
test_that("endpoints fail when given args via dots", {
151328
dots_error <- "`...` must be empty"
152329

0 commit comments

Comments
 (0)