Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- {os: ubuntu-latest, r: '4.1.0'}

env:
getRad_nl_api_key: ${{ secrets.GETRAD_NL_API_KEY }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/regular-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}

env:
getRad_nl_api_key: ${{ secrets.GETRAD_NL_API_KEY }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
test-coverage:
runs-on: ubuntu-latest
env:
getRad_nl_api_key: ${{ secrets.GETRAD_NL_API_KEY }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
Expand Down
48 changes: 29 additions & 19 deletions tests/testthat/test-get_pvol_nl.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ test_that("Pvol for the Netherlands can be downloaded", {
skip_if(Sys.which("KNMI_vol_h5_to_ODIM_h5") == "")
skip_if_offline(host = "api.dataplatform.knmi.nl")

# make sure local env is used by keyring so that api key can be set
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"
# First see if a key can be retrieved if not make sure env is used as a keyring backend
if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) {
withr::local_options(list(
"keyring_backend" = "env"
))
}
# If no key can be retrieved from the current backend set the key to the anonymous key of KNMI
if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) {
# get public key here https://developer.dataplatform.knmi.nl/open-data-api#token
withr::local_envvar(
list(
"getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9"
)
)
)
}
time <- as.POSIXct("2024-4-4 20:00:00", tz = "Europe/Helsinki")
expect_s3_class(
get_pvol("nlhrw", time, param = "all"),
"pvol"
)
pvol <- expect_s3_class(get_pvol("nlhrw", time, param = "all"), "pvol")
expect_true(bioRad::is.pvol(pvol))
expect_identical(
Expand All @@ -31,15 +32,24 @@ test_that("Pvol for the Netherlands can be downloaded. Incorrect converter resul

# make sure local env is used by keyring so that api key can be set
withr::local_options(list(
"keyring_backend" = "env",
"getRad.nl_converter" = "ls"
))
# get public key here https://developer.dataplatform.knmi.nl/open-data-api#token
withr::local_envvar(
list(
"getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9"

# First see if a key can be retrieved if not make sure env is used as a keyring backend
if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) {
withr::local_options(list(
"keyring_backend" = "env"
))
}
# If no key can be retrieved from the current backend set the key to the anonymous key of KNMI
if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) {
# get public key here https://developer.dataplatform.knmi.nl/open-data-api#token
withr::local_envvar(
list(
"getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9"
)
)
)
}
time <- as.POSIXct("2024-4-4 20:00:00", tz = "Europe/Helsinki")
expect_error(
get_pvol("nlhrw", time, param = "all"),
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-get_pvol_ro.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ test_that("Check if the available attributes changed", {
unique() |>
gsub(pattern = ".hdf", replacement = "") |>
sort(),
c("KDP", "RhoHV", "V", "ZDR", "dBZ") |> sort()
c("Height", "KDP", "RhoHV", "V", "ZDR", "dBR", "dBZ") |> sort()
# Height and dBR are none polar files
)
})
test_that("Pvol for Romania can be downloaded", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-get_vpts_coverage_rmi.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test_that("get_vpts_coverage_rmi() returns known radars and years", {

expect_in(
lubridate::year(cov$date),
seq(2019, 2025)
seq(2019, lubridate::year(Sys.Date()))
)
})

Expand Down