Skip to content

Commit

Permalink
Merge branch 'dev' into ndefries/less-sensitive-missing-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nmdefries committed Mar 4, 2024
2 parents 3a21d59 + fe42abc commit 5d63158
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
9 changes: 6 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
## Features

## Patches
- Fixed failure when passing `as_of` values in `Date` format to
`pub_covidcast` while caching is enabled (#259)
- Fix failure in `pub_covidcast` when user doesn't pass `geo_values` or `time_values`, even though those arguments have defaults (#268).
- Fix failure when passing `as_of` values in `Date` format to
`pub_covidcast` while caching is enabled (#259).
- For `pub_covidcast` data source `nchs-mortality`, parse dates as `epiweek`
and expect `epiweek` inputs from user (#260).
- Fix failure in `pub_covidcast` when user doesn't pass `geo_values` or
`time_values`, even though those arguments have defaults (#268).

# epidatr 1.1.0

Expand Down
17 changes: 15 additions & 2 deletions R/endpoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,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 All @@ -1053,8 +1060,14 @@ pub_covidcast <- function(
c("day", "week")
),
create_epidata_field_info("geo_value", "text"),
create_epidata_field_info("time_value", "date"),
create_epidata_field_info("issue", "date"),
create_epidata_field_info("time_value", switch(time_type,
day = "date",
week = "epiweek"
)),
create_epidata_field_info("issue", switch(time_type,
day = "date",
week = "epiweek"
)),
create_epidata_field_info("lag", "int"),
create_epidata_field_info("value", "float"),
create_epidata_field_info("stderr", "float"),
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 @@ -518,6 +518,17 @@ test_that("pub_covid_hosp_state_timeseries supports versioned queries", {
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")
})

test_that("pub_covidcast catches missing args for args without defaults", {
expect_no_error(pub_covidcast(
source = "jhu-csse",
Expand Down

0 comments on commit 5d63158

Please sign in to comment.