Skip to content

Commit

Permalink
error if nchs requested not weekly
Browse files Browse the repository at this point in the history
  • Loading branch information
nmdefries committed Mar 1, 2024
1 parent 0424f6b commit 0209e95
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/endpoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,13 @@ pub_covidcast <- function(
as_of <- parse_timeset_input(as_of)
issues <- parse_timeset_input(issues)

if (source == "nchs-mortality" && time_type != "week") {
cli::cli_abort(
"{source} data is only available at the week level",
class = "epidatr__nchs_week_only"
)
}

create_epidata_call(
"covidcast/",
list(
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-endpoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,14 @@ test_that("pub_covid_hosp_state_timeseries supports versioned queries", {
expect_identical(epidata_call$params$as_of, 20220101)
expect_identical(epidata_call$params$lag, NULL)
})

test_that("nchs-mortality call fails if time_type not week", {
expect_error(pub_covidcast(
source = "nchs-mortality",
signals = "signal",
time_type = "day",
geo_type = "state",
time_values = "*",
geo_values = "*"
), class = "epidatr__nchs_week_only")
})

0 comments on commit 0209e95

Please sign in to comment.