Skip to content

Commit

Permalink
test(data): ref objects
Browse files Browse the repository at this point in the history
  • Loading branch information
dimfalk committed Nov 12, 2022
1 parent 529d535 commit fbcde7c
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 34 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ Suggests:
covr,
cyphr,
sodium,
testthat (>= 3.0.0)
testthat (>= 3.0.0),
withr
Config/testthat/edition: 3
27 changes: 15 additions & 12 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 5 additions & 5 deletions tests/testthat/test-fetch_token.R
Original file line number Diff line number Diff line change
@@ -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: ...
})
10 changes: 5 additions & 5 deletions tests/testthat/test-get_measure.R
Original file line number Diff line number Diff line change
@@ -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)
})
10 changes: 5 additions & 5 deletions tests/testthat/test-get_publicdata.R
Original file line number Diff line number Diff line change
@@ -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)
})
6 changes: 3 additions & 3 deletions tests/testthat/test-print_at.R
Original file line number Diff line number Diff line change
@@ -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())

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-print_rt.R
Original file line number Diff line number Diff line change
@@ -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())

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit fbcde7c

Please sign in to comment.