From d5766425ee00294c9f01c0d42749a8d64fa52903 Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 14 Oct 2025 11:46:14 +0200 Subject: [PATCH 1/7] add tests that run locally to test attributes of pvols --- tests/testthat/test-get_pvol_attributes.R | 105 ++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 tests/testthat/test-get_pvol_attributes.R diff --git a/tests/testthat/test-get_pvol_attributes.R b/tests/testthat/test-get_pvol_attributes.R new file mode 100644 index 0000000..d5e1019 --- /dev/null +++ b/tests/testthat/test-get_pvol_attributes.R @@ -0,0 +1,105 @@ +check_attributes <- function(x, wr_df) { + expect_s3_class(x, "pvol") + 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( + 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() + skip_if( + inherits(try(get_secret("dk_api_key"), silent = TRUE), "try-error"), + message = "Because no key for Denmark is available in the testing environment" + ) + 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) +}) From dcaab8d75c1b31fb99b4d0e5a6a01359bb478aed Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 14 Oct 2025 16:39:18 +0200 Subject: [PATCH 2/7] add release_bullets function so that a reminder is made for next release to update codemeta and cffr --- R/zzz.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/R/zzz.R b/R/zzz.R index 676f966..6532571 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -34,3 +34,13 @@ 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)" + ) +} From f3cee8f90b42de4e7c31cbf4a42e2536bd45d3d6 Mon Sep 17 00:00:00 2001 From: Bart Date: Wed, 15 Oct 2025 13:12:57 +0200 Subject: [PATCH 3/7] Check if is.pvol --- tests/testthat/test-get_pvol_attributes.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test-get_pvol_attributes.R b/tests/testthat/test-get_pvol_attributes.R index d5e1019..eb3b3e9 100644 --- a/tests/testthat/test-get_pvol_attributes.R +++ b/tests/testthat/test-get_pvol_attributes.R @@ -1,5 +1,6 @@ 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 & From d254ccc1f5cfc1823c40e594c63afa6fc75b2ebc Mon Sep 17 00:00:00 2001 From: Bart Date: Thu, 16 Oct 2025 09:14:19 +0200 Subject: [PATCH 4/7] add test for release_bullets --- tests/testthat/test-utils.R | 4 ++++ 1 file changed, 4 insertions(+) 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) +}) From 3f2f0c8e4c792c523b5b30927303f1fdf5d1407c Mon Sep 17 00:00:00 2001 From: Bart Date: Thu, 6 Nov 2025 17:18:27 +0100 Subject: [PATCH 5/7] fix wavelength error --- tests/testthat/test-get_pvol_attributes.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-get_pvol_attributes.R b/tests/testthat/test-get_pvol_attributes.R index eb3b3e9..2287baa 100644 --- a/tests/testthat/test-get_pvol_attributes.R +++ b/tests/testthat/test-get_pvol_attributes.R @@ -18,7 +18,8 @@ check_attributes <- function(x, wr_df) { expect_equal(x$geo$lon, radar_df$longitude, tolerance = .001) expect_equal(x$attributes$where$lon, radar_df$longitude, tolerance = .001) expect_equal( - x$attributes$how$wavelength, + # 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 ) From ccdde95daa7a655524429a13ef4b12198abc8b3b Mon Sep 17 00:00:00 2001 From: bart1 <1662852+bart1@users.noreply.github.com> Date: Tue, 18 Nov 2025 11:29:46 +0100 Subject: [PATCH 6/7] Add release bullet for local tests with API keys --- R/zzz.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/zzz.R b/R/zzz.R index 6532571..0104168 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -41,6 +41,7 @@ release_bullets <- function() { c( "Update codemeta.json with: `codemetar::write_codemeta()`", "update CITATION.cff with `cffr::cff_write(dependencies = FALSE)` - (after incrementing version)" + (after incrementing version)", + "Run local tests to ensure attributes and radars with api keys work" ) } From b19614765e83b87a9a952dac5f470a81540b57db Mon Sep 17 00:00:00 2001 From: bart1 <1662852+bart1@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:59:46 +0100 Subject: [PATCH 7/7] Remove skip condition for Denmark API key test Removed conditional skip for Denmark API key in tests. --- tests/testthat/test-get_pvol_attributes.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/testthat/test-get_pvol_attributes.R b/tests/testthat/test-get_pvol_attributes.R index 2287baa..b8bf686 100644 --- a/tests/testthat/test-get_pvol_attributes.R +++ b/tests/testthat/test-get_pvol_attributes.R @@ -90,10 +90,6 @@ test_that("Check Netherland", { test_that("Check Denmark", { skip_on_cran() skip_on_ci() - skip_if( - inherits(try(get_secret("dk_api_key"), silent = TRUE), "try-error"), - message = "Because no key for Denmark is available in the testing environment" - ) pv <- get_pvol("dkbor", t) check_attributes(pv, wr_df) })