Skip to content

Commit 70bea5f

Browse files
authored
Merge pull request #164 from aloftdata/fix_regular_checks
Fix regular checks
2 parents 8f780ca + 3840f33 commit 70bea5f

6 files changed

Lines changed: 35 additions & 21 deletions

File tree

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
- {os: ubuntu-latest, r: '4.1.0'}
3030

3131
env:
32+
getRad_nl_api_key: ${{ secrets.GETRAD_NL_API_KEY }}
3233
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
3334
R_KEEP_PKG_SOURCE: yes
3435

.github/workflows/regular-checks.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
2323

2424
env:
25+
getRad_nl_api_key: ${{ secrets.GETRAD_NL_API_KEY }}
2526
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
2627
R_KEEP_PKG_SOURCE: yes
2728

.github/workflows/test-coverage.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
test-coverage:
1414
runs-on: ubuntu-latest
1515
env:
16+
getRad_nl_api_key: ${{ secrets.GETRAD_NL_API_KEY }}
1617
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1718

1819
steps:

tests/testthat/test-get_pvol_nl.R

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@ test_that("Pvol for the Netherlands can be downloaded", {
22
skip_if(Sys.which("KNMI_vol_h5_to_ODIM_h5") == "")
33
skip_if_offline(host = "api.dataplatform.knmi.nl")
44

5-
# make sure local env is used by keyring so that api key can be set
6-
withr::local_options(list(
7-
"keyring_backend" = "env"
8-
))
9-
# get public key here https://developer.dataplatform.knmi.nl/open-data-api#token
10-
withr::local_envvar(
11-
list(
12-
"getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9"
5+
# First see if a key can be retrieved if not make sure env is used as a keyring backend
6+
if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) {
7+
withr::local_options(list(
8+
"keyring_backend" = "env"
9+
))
10+
}
11+
# If no key can be retrieved from the current backend set the key to the anonymous key of KNMI
12+
if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) {
13+
# get public key here https://developer.dataplatform.knmi.nl/open-data-api#token
14+
withr::local_envvar(
15+
list(
16+
"getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9"
17+
)
1318
)
14-
)
19+
}
1520
time <- as.POSIXct("2024-4-4 20:00:00", tz = "Europe/Helsinki")
16-
expect_s3_class(
17-
get_pvol("nlhrw", time, param = "all"),
18-
"pvol"
19-
)
2021
pvol <- expect_s3_class(get_pvol("nlhrw", time, param = "all"), "pvol")
2122
expect_true(bioRad::is.pvol(pvol))
2223
expect_identical(
@@ -31,15 +32,24 @@ test_that("Pvol for the Netherlands can be downloaded. Incorrect converter resul
3132

3233
# make sure local env is used by keyring so that api key can be set
3334
withr::local_options(list(
34-
"keyring_backend" = "env",
3535
"getRad.nl_converter" = "ls"
3636
))
37-
# get public key here https://developer.dataplatform.knmi.nl/open-data-api#token
38-
withr::local_envvar(
39-
list(
40-
"getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9"
37+
38+
# First see if a key can be retrieved if not make sure env is used as a keyring backend
39+
if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) {
40+
withr::local_options(list(
41+
"keyring_backend" = "env"
42+
))
43+
}
44+
# If no key can be retrieved from the current backend set the key to the anonymous key of KNMI
45+
if (rlang::is_error(rlang::catch_cnd(getRad::get_secret("nl_api_key")))) {
46+
# get public key here https://developer.dataplatform.knmi.nl/open-data-api#token
47+
withr::local_envvar(
48+
list(
49+
"getRad_nl_api_key" = "eyJvcmciOiI1ZTU1NGUxOTI3NGE5NjAwMDEyYTNlYjEiLCJpZCI6ImVlNDFjMWI0MjlkODQ2MThiNWI4ZDViZDAyMTM2YTM3IiwiaCI6Im11cm11cjEyOCJ9"
50+
)
4151
)
42-
)
52+
}
4353
time <- as.POSIXct("2024-4-4 20:00:00", tz = "Europe/Helsinki")
4454
expect_error(
4555
get_pvol("nlhrw", time, param = "all"),

tests/testthat/test-get_pvol_ro.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ test_that("Check if the available attributes changed", {
1111
unique() |>
1212
gsub(pattern = ".hdf", replacement = "") |>
1313
sort(),
14-
c("KDP", "RhoHV", "V", "ZDR", "dBZ") |> sort()
14+
c("Height", "KDP", "RhoHV", "V", "ZDR", "dBR", "dBZ") |> sort()
15+
# Height and dBR are none polar files
1516
)
1617
})
1718
test_that("Pvol for Romania can be downloaded", {

tests/testthat/test-get_vpts_coverage_rmi.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test_that("get_vpts_coverage_rmi() returns known radars and years", {
4141

4242
expect_in(
4343
lubridate::year(cov$date),
44-
seq(2019, 2025)
44+
seq(2019, lubridate::year(Sys.Date()))
4545
)
4646
})
4747

0 commit comments

Comments
 (0)