diff --git a/R/zzz.R b/R/zzz.R index 676f966..0104168 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -34,3 +34,14 @@ invisible() } rlang::on_load(rlang::local_use_cli(inline = TRUE)) + + +# see ?usethis::use_release_issue() #nolint +release_bullets <- function() { + c( + "Update codemeta.json with: `codemetar::write_codemeta()`", + "update CITATION.cff with `cffr::cff_write(dependencies = FALSE)` + (after incrementing version)", + "Run local tests to ensure attributes and radars with api keys work" + ) +} diff --git a/tests/testthat/test-get_pvol_attributes.R b/tests/testthat/test-get_pvol_attributes.R new file mode 100644 index 0000000..b8bf686 --- /dev/null +++ b/tests/testthat/test-get_pvol_attributes.R @@ -0,0 +1,103 @@ +check_attributes <- function(x, wr_df) { + expect_s3_class(x, "pvol") + expect_true(bioRad::is.pvol(x)) + expect_true(x$radar %in% wr_df$radar) + radar_df <- wr_df[ + x$radar == wr_df$radar & + (as.logical(wr_df$status) | wr_df$country == "United States"), + ] + expect_equal(nrow(radar_df), 1) + expect_equal(x$geo$height, radar_df$heightantenna, tolerance = .001) + expect_equal( + x$attributes$where$height, + radar_df$heightantenna, + tolerance = .001 + ) + expect_equal(x$geo$lat, radar_df$latitude, tolerance = .001) + expect_equal(x$attributes$where$lat, radar_df$latitude, tolerance = .001) + expect_equal(x$geo$lon, radar_df$longitude, tolerance = .001) + expect_equal(x$attributes$where$lon, radar_df$longitude, tolerance = .001) + expect_equal( + # For the Netherlands wavelength get a dim 1, using c() drops it + c(x$attributes$how$wavelength), + 299792458 / (radar_df$frequency * 10^9) * 100, + tolerance = .005 + ) +} +wr_df <- get_weather_radars(source = c("nexrad", "opera")) +t <- Sys.time() - 24 * 60 * 60 + +test_that("Check Germany", { + skip_on_cran() + skip_on_ci() + pv <- get_pvol("depro", t) + check_attributes(pv, wr_df) +}) + +test_that("Check Czechia", { + skip_on_cran() + skip_on_ci() + + pv <- get_pvol("czbrd", t) + check_attributes(pv, wr_df) +}) + +test_that("Check Estonia", { + skip_on_cran() + skip_on_ci() + pv <- get_pvol("eehar", t) + check_attributes(pv, wr_df) +}) + +test_that("Check Finland", { + skip_on_cran() + skip_on_ci() + pv <- get_pvol("fikor", t) + check_attributes(pv, wr_df) +}) + +test_that("Check Romania", { + skip_on_cran() + skip_on_ci() + pv <- get_pvol("roora", t) + check_attributes(pv, wr_df) +}) + +test_that("Check Slovakia", { + skip_on_cran() + skip_on_ci() + pv <- get_pvol("skkoj", t) + check_attributes(pv, wr_df) +}) + +test_that("Check Netherland", { + skip_on_cran() + skip_on_ci() + withr::local_options(list( + "keyring_backend" = "env" + )) + # get public key here https://developer.dataplatform.knmi.nl/open-data-api#token + withr::local_envvar( + list( + "getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9" + ) + ) + skip_if(Sys.which("KNMI_vol_h5_to_ODIM_h5") == "") + pv <- get_pvol("nldhl", t) + check_attributes(pv, wr_df) +}) + +test_that("Check Denmark", { + skip_on_cran() + skip_on_ci() + pv <- get_pvol("dkbor", t) + check_attributes(pv, wr_df) +}) + + +test_that("Check US", { + skip_on_cran() + skip_on_ci() + pv <- get_pvol("KABR", t) + check_attributes(pv, wr_df) +}) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 53c6edb..df844e8 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -58,3 +58,7 @@ test_that("fetch_from_url_raw warns on failing url", { 200 ) }) +testthat::test_that("release_bullets returns expected", { + expect_type(release_bullets(), "character") + expect_gte(length(release_bullets()), 1) +})