From a3d4ca7445c43a9fad82113a1575c35a2ecb9e8a Mon Sep 17 00:00:00 2001 From: Bart Date: Mon, 17 Aug 2026 15:28:36 +0200 Subject: [PATCH] skip if package is not installed --- tests/testthat/test-get_pvol.R | 3 +++ tests/testthat/test-get_pvol_at.R | 9 ++++++--- tests/testthat/test-get_pvol_us.R | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-get_pvol.R b/tests/testthat/test-get_pvol.R index b9c2ffc..720a045 100644 --- a/tests/testthat/test-get_pvol.R +++ b/tests/testthat/test-get_pvol.R @@ -130,6 +130,7 @@ test_that("multiple timestamps and radars work", { test_that("Mixed radar vector (single timestamp)", { skip_if_offline() + skip_if_not_installed("vol2birdR", "1.3.0") time_utc <- lubridate::as_datetime("2021-01-20 05:01:00") suppressMessages(pvols <- getRad::get_pvol(c("KABR", "finur"), time_utc)) expect_true(is.list(pvols)) @@ -152,6 +153,8 @@ test_that("Mixed radar vector (single timestamp)", { test_that("Mixed radar vector + 9 minute interval", { skip_if_offline() + skip_if_not_installed("vol2birdR", "1.3.0") + time_utc <- lubridate::as_datetime("2025-01-20 03:55:50") dt_int <- lubridate::interval(time_utc, time_utc + lubridate::minutes(9)) suppressMessages(pvols <- getRad::get_pvol(c("KABR", "fikan"), dt_int)) diff --git a/tests/testthat/test-get_pvol_at.R b/tests/testthat/test-get_pvol_at.R index e77f9db..892b4fb 100644 --- a/tests/testthat/test-get_pvol_at.R +++ b/tests/testthat/test-get_pvol_at.R @@ -1,5 +1,5 @@ test_that("Pvol for hochficht in austria can be downloaded", { - skip_if_offline("public.hub.geosphere.at") + skip_if_offline(host = "public.hub.geosphere.at") time <- as.POSIXct(Sys.time() - 10000, tz = "Europe/Helsinki") pvol <- expect_s3_class(get_pvol("hochficht", time, param = "all"), "pvol") expect_true(bioRad::is.pvol(pvol)) @@ -10,7 +10,7 @@ test_that("Pvol for hochficht in austria can be downloaded", { }) test_that("Pvol for hochficht in austria can be downloaded", { - skip_if_offline("public.hub.geosphere.at") + skip_if_offline(host = "public.hub.geosphere.at") time <- as.POSIXct( Sys.time() - 10000 - 24 * 3 * 60 * 60, tz = "Europe/Helsinki" @@ -21,7 +21,10 @@ test_that("Pvol for hochficht in austria can be downloaded", { ) }) test_that("hochficht can be combined with other radars", { - skip_if_offline("public.hub.geosphere.at") + skip_if_offline(host = "public.hub.geosphere.at") + skip_if_offline(host = "unidata-nexrad-level2.s3.amazonaws.com") + skip_if_offline(host = "opendata.dwd.de") + skip_if_not_installed("vol2birdR", "1.3.0") suppressMessages(expect_type( pvol_lst <- get_pvol( c("depro", "hochficht", "KABX"), diff --git a/tests/testthat/test-get_pvol_us.R b/tests/testthat/test-get_pvol_us.R index 02d6120..0c8e28b 100644 --- a/tests/testthat/test-get_pvol_us.R +++ b/tests/testthat/test-get_pvol_us.R @@ -3,6 +3,8 @@ dt_int <- lubridate::interval(time_utc, time_utc + lubridate::minutes(9)) test_that("NEXRAD polar volume can be downloaded", { skip_if_offline(host = "unidata-nexrad-level2.s3.amazonaws.com") + skip_if_not_installed("vol2birdR", "1.3.0") + suppressMessages( expect_s3_class( getRad::get_pvol("KABR", time_utc), @@ -24,6 +26,8 @@ test_that("pvol us internal functions", { test_that("NEXRAD polar volume correct time is downloaded", { skip_if_offline(host = "unidata-nexrad-level2.s3.amazonaws.com") + skip_if_not_installed("vol2birdR", "1.3.0") + t <- as.POSIXct("2025-1-10 18:00:00", tz = "UTC") suppressMessages(expect_identical( getRad::get_pvol("KABX", t)$datetime,