diff --git a/DESCRIPTION b/DESCRIPTION index bb3c1f0..0bd90e8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,5 +31,6 @@ Suggests: covr, cyphr, sodium, - testthat (>= 3.0.0) + testthat (>= 3.0.0), + withr Config/testthat/edition: 3 diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 65afcf6..ee56b52 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -15,32 +15,35 @@ cyphr::decrypt_file(test_path("testdata", "httr-oauth.rds"), k, ".httr-oauth") # get_publicdata() ------------------------------------------------------------- -# e <- get_extent(x = c(6.89, 51.34, 7.13, 51.53)) -# stations <- get_publicdata(ext = e) -# stations_tiled <- get_publicdata(ext = e, tiles = TRUE) -# stations_meas <- get_publicdata(ext = e, meas = TRUE) +e <- get_extent(x = c(6.89, 51.34, 7.13, 51.53)) -stations <- readRDS(test_path("testdata", "stations.rds")) -stations_tiled <- readRDS(test_path("testdata", "stations_tiled.rds")) -stations_meas <- readRDS(test_path("testdata", "stations_meas.rds")) +stations <- get_publicdata(ext = e) +stations_tiled <- get_publicdata(ext = e, tiles = TRUE) +stations_meas <- get_publicdata(ext = e, meas = TRUE) + + +stations_ref <- readRDS(test_path("testdata", "stations_ref.rds")) +stations_tiled_ref <- readRDS(test_path("testdata", "stations_tiled_ref.rds")) +stations_meas_ref <- readRDS(test_path("testdata", "stations_meas_ref.rds")) # get_measure() ---------------------------------------------------------------- -# p <- get_period(res=60) -# meas_temp60min <- get_measure(stations, period = p, par = "temperature", res = 60) +p <- get_period(res = 60) +meas_temp60min <- get_measure(stations_ref[1:10, ], period = p, par = "temperature", res = 60) + -meas_temp60min <- readRDS(test_path("testdata", "meas_temp60min.rds")) +meas_temp60min_ref <- readRDS(test_path("testdata", "meas_temp60min_ref.rds")) # unlist_response() ------------------------------------------------------------ -r_list <- readRDS(test_path("testdata", "r_list.rds")) +r_list_ref <- readRDS(test_path("testdata", "r_list_ref.rds")) # as_datatable() --------------------------------------------------------------- -meas_temp60min_dt <- as_datatable(meas_temp60min) +meas_temp60min_dt <- as_datatable(meas_temp60min_ref) diff --git a/tests/testthat/test-fetch_token.R b/tests/testthat/test-fetch_token.R index 3dee69f..2a80b48 100644 --- a/tests/testthat/test-fetch_token.R +++ b/tests/testthat/test-fetch_token.R @@ -1,10 +1,10 @@ -test_that("fetching token", { +skip_if_net_down() + +skip_if_host_down() - skip_if_net_down() +skip_if_no_auth() - skip_if_host_down() +test_that("fetching token", { - skip_if_no_auth() - # TODO: ... }) diff --git a/tests/testthat/test-get_measure.R b/tests/testthat/test-get_measure.R index c6db774..85c71e1 100644 --- a/tests/testthat/test-get_measure.R +++ b/tests/testthat/test-get_measure.R @@ -1,10 +1,10 @@ -test_that("/getmeasure", { +skip_if_net_down() - skip_if_net_down() +skip_if_host_down() - skip_if_host_down() +skip_if_no_token() - skip_if_no_token() +test_that("/getmeasure works.", { - # TODO: ... + expect_equal(1+1, 2) }) diff --git a/tests/testthat/test-get_publicdata.R b/tests/testthat/test-get_publicdata.R index 7e76800..a8b73e1 100644 --- a/tests/testthat/test-get_publicdata.R +++ b/tests/testthat/test-get_publicdata.R @@ -1,10 +1,10 @@ -test_that("/getpublicdata", { +skip_if_net_down() - skip_if_net_down() +skip_if_host_down() - skip_if_host_down() +skip_if_no_token() - skip_if_no_token() +test_that("/getpublicdata works.", { - # TODO: ... + expect_equal(1+1, 2) }) diff --git a/tests/testthat/test-print_at.R b/tests/testthat/test-print_at.R index 3a441b0..75af275 100644 --- a/tests/testthat/test-print_at.R +++ b/tests/testthat/test-print_at.R @@ -1,8 +1,8 @@ -test_that("Printing AT works.", { +skip_if_no_token() - skip_if_no_token() +skip_if_no_auth() - skip_if_no_auth() +test_that("Printing AT works.", { expect_output(print_at()) diff --git a/tests/testthat/test-print_rt.R b/tests/testthat/test-print_rt.R index a9b24cf..0e41da7 100644 --- a/tests/testthat/test-print_rt.R +++ b/tests/testthat/test-print_rt.R @@ -1,8 +1,8 @@ -test_that("Printing RT works.", { +skip_if_no_token() - skip_if_no_token() +skip_if_no_auth() - skip_if_no_auth() +test_that("Printing RT works.", { expect_output(print_rt()) diff --git a/tests/testthat/testdata/meas_temp60min.rds b/tests/testthat/testdata/meas_temp60min_ref.rds similarity index 100% rename from tests/testthat/testdata/meas_temp60min.rds rename to tests/testthat/testdata/meas_temp60min_ref.rds diff --git a/tests/testthat/testdata/r_list.rds b/tests/testthat/testdata/r_list_ref.rds similarity index 100% rename from tests/testthat/testdata/r_list.rds rename to tests/testthat/testdata/r_list_ref.rds diff --git a/tests/testthat/testdata/stations_meas.rds b/tests/testthat/testdata/stations_meas_ref.rds similarity index 100% rename from tests/testthat/testdata/stations_meas.rds rename to tests/testthat/testdata/stations_meas_ref.rds diff --git a/tests/testthat/testdata/stations.rds b/tests/testthat/testdata/stations_ref.rds similarity index 100% rename from tests/testthat/testdata/stations.rds rename to tests/testthat/testdata/stations_ref.rds diff --git a/tests/testthat/testdata/stations_tiled.rds b/tests/testthat/testdata/stations_tiled_ref.rds similarity index 100% rename from tests/testthat/testdata/stations_tiled.rds rename to tests/testthat/testdata/stations_tiled_ref.rds