Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions R/endpoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ pub_covid_hosp_facility_lookup <- function(
zip = NULL,
fips_code = NULL,
fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("state", state, len = 1, required = FALSE)
assert_character_param("ccn", ccn, len = 1, required = FALSE)
assert_character_param("city", city, len = 1, required = FALSE)
Expand Down Expand Up @@ -171,6 +173,8 @@ pub_covid_hosp_facility <- function(
...,
publication_dates = NULL,
fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("hospital_pks", hospital_pks)
assert_timeset_param("collection_weeks", collection_weeks)
assert_timeset_param("publication_dates", publication_dates, required = FALSE)
Expand Down Expand Up @@ -465,6 +469,8 @@ pub_covid_hosp_facility <- function(
#' @export
#
pub_covid_hosp_state_timeseries <- function(states, dates, ..., issues = NULL, fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("states", states)
assert_timeset_param("dates", dates)
assert_timeset_param("issues", issues, required = FALSE)
Expand Down Expand Up @@ -711,6 +717,8 @@ pub_covidcast <- function(
issues = NULL,
lag = NULL,
fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

# Check parameters
if (
missing(source) ||
Expand Down Expand Up @@ -918,6 +926,8 @@ pvt_dengue_sensors <- function(auth, names, locations, epiweeks, fetch_args = fe
#' @keywords endpoint
#' @export
pub_ecdc_ili <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("regions", regions)
assert_timeset_param("epiweeks", epiweeks)
assert_timeset_param("issues", issues, required = FALSE)
Expand Down Expand Up @@ -975,6 +985,8 @@ pub_ecdc_ili <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, fetc
#' @keywords endpoint
#' @export
pub_flusurv <- function(locations, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("locations", locations)
assert_timeset_param("epiweeks", epiweeks)
assert_timeset_param("issues", issues, required = FALSE)
Expand Down Expand Up @@ -1031,6 +1043,8 @@ pub_flusurv <- function(locations, epiweeks, ..., issues = NULL, lag = NULL, fet
#' @keywords endpoint
#' @export
pub_fluview_clinical <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("regions", regions)
assert_timeset_param("epiweeks", epiweeks)
assert_timeset_param("issues", issues, required = FALSE)
Expand Down Expand Up @@ -1134,6 +1148,8 @@ pub_fluview <- function(
lag = NULL,
auth = NULL,
fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("regions", regions)
assert_timeset_param("epiweeks", epiweeks)
assert_timeset_param("issues", issues, required = FALSE)
Expand Down Expand Up @@ -1284,6 +1300,8 @@ pvt_ght <- function(auth, locations, epiweeks, query, fetch_args = fetch_args_li
#' @keywords endpoint
#' @export
pub_kcdc_ili <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("regions", regions)
assert_timeset_param("epiweeks", epiweeks)
assert_timeset_param("issues", issues, required = FALSE)
Expand Down Expand Up @@ -1413,6 +1431,8 @@ pub_nidss_dengue <- function(locations, epiweeks, fetch_args = fetch_args_list()
#' @keywords endpoint
#' @export
pub_nidss_flu <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("regions", regions)
assert_timeset_param("epiweeks", epiweeks)
assert_timeset_param("issues", issues, required = FALSE)
Expand Down Expand Up @@ -1544,6 +1564,8 @@ pub_nowcast <- function(locations, epiweeks, fetch_args = fetch_args_list()) {
#' @keywords endpoint
#' @export
pub_paho_dengue <- function(regions, epiweeks, ..., issues = NULL, lag = NULL, fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("regions", regions)
assert_timeset_param("epiweeks", epiweeks)
assert_timeset_param("issues", issues, required = FALSE)
Expand Down Expand Up @@ -1699,6 +1721,8 @@ pvt_sensors <- function(auth, names, locations, epiweeks, fetch_args = fetch_arg
#' @keywords endpoint
#' @export
pvt_twitter <- function(auth, locations, ..., dates = NULL, epiweeks = NULL, fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("auth", auth, len = 1)
assert_character_param("locations", locations)
assert_timeset_param("dates", dates, required = FALSE)
Expand Down Expand Up @@ -1767,6 +1791,8 @@ pub_wiki <- function(
hours = NULL,
language = "en",
fetch_args = fetch_args_list()) {
rlang::check_dots_empty()

assert_character_param("articles", articles)
assert_timeset_param("dates", dates, required = FALSE)
assert_timeset_param("epiweeks", epiweeks, required = FALSE)
Expand Down
2 changes: 2 additions & 0 deletions R/epidatacall.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ fetch_args_list <- function(
dry_run = FALSE,
debug = FALSE,
format_type = c("json", "classic", "csv")) {
rlang::check_dots_empty()

assert_character(fields, null.ok = TRUE, any.missing = FALSE)
assert_logical(disable_date_parsing, null.ok = FALSE, len = 1L, any.missing = FALSE)
assert_logical(disable_data_frame_parsing, null.ok = FALSE, len = 1L, any.missing = FALSE)
Expand Down
102 changes: 102 additions & 0 deletions tests/testthat/test-endpoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,105 @@ test_that("basic_epidata_call", {
fetch_args = fetch_args_list(dry_run = TRUE)
) %>% request_url())
})

test_that("endpoints fail when given args via dots", {
dots_error <- "`...` must be empty"

# time value/epiweek arg is passed erroneously as `date_range`
expect_error(
pub_covid_hosp_facility_lookup(
state = "fl",
date_range = 20200101
),
regexp = dots_error
)
expect_error(
pub_covid_hosp_facility(
hospital_pks = "100075",
date_range = epirange(20200101, 20200501)
),
regexp = dots_error
)
expect_error(
pub_covid_hosp_state_timeseries(
states = "fl",
date_range = epirange(20200101, 20200501)
),
regexp = dots_error
)
expect_error(
pub_covidcast(
source = "jhu-csse",
signals = "confirmed_7dav_incidence_prop",
time_type = "day",
geo_type = "state",
date_range = epirange(20200601, 20200801),
geo_values = "ca,fl"
),
regexp = dots_error
)
expect_error(
pub_ecdc_ili(
regions = "austria",
date_range = epirange(201201, 202001)
),
regexp = dots_error
)
expect_error(
pub_flusurv(
locations = "CA",
date_range = epirange(201201, 202001)
),
regexp = dots_error
)
expect_error(
pub_fluview_clinical(
regions = "nat",
date_range = epirange(201601, 201701)
),
regexp = dots_error
)
expect_error(
pub_fluview(
regions = "nat",
date_range = epirange(201601, 201701)
),
regexp = dots_error
)
expect_error(
pub_kcdc_ili(
regions = "?",
date_range = epirange(201201, 202001)
),
regexp = dots_error
)
expect_error(
pub_nidss_flu(
regions = "taipei",
date_range = epirange(201201, 202001)
),
regexp = dots_error
)
expect_error(
pub_paho_dengue(
regions = "ca",
date_range = epirange(201201, 202001)
),
regexp = dots_error
)
expect_error(
pvt_twitter(
auth = "yourkey",
locations = "CA",
date_range = epirange(201501, 202001)
),
regexp = dots_error
)
expect_error(
pub_wiki(
articles = "avian_influenza",
date_range = epirange(201501, 202001)
),
regexp = dots_error
)
})