Skip to content

Commit

Permalink
try skip each
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsumner committed Apr 21, 2023
1 parent e19dfb0 commit 4e46534
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 18 deletions.
2 changes: 0 additions & 2 deletions tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
library(testthat)
library(ceramic)

skip_if_offline()
skip_if(is.null(get_api_key()))
test_check("ceramic")
2 changes: 2 additions & 0 deletions tests/testthat/test-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
context("test-cache")

test_that("caching is sensible", {
skip_on_cran()
skip_if(is.null(get_api_key()))

## this hits zoom 13 and should give 16 tiles
x <- get_tiles(cbind(0, 0), buffer = 5000, dimension = c(15, 16))
Expand Down
5 changes: 4 additions & 1 deletion tests/testthat/test-formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ tv <- function() {

classes <- list(tre(), tr(), tv(), wkbll, wkbpr, grdll, grdpr)
##for (i in seq_along(classes)) cc_location(classes[[i]])
test_that("multiplication works", {
test_that("formats work", {
skip_on_cran()
skip_if(is.null(get_api_key()))

for (i in seq_along(classes)) {
expect_s4_class(cc_location(classes[[i]], dimension = c(4, 4)), "SpatRaster")
}
Expand Down
14 changes: 3 additions & 11 deletions tests/testthat/test-get.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@ context("test-get")

test_that("getting tiles works", {

skip_on_cran()
skip_if(is.null(get_api_key()))

expect_silent(ceramic_cache())

#f <- get_files(cbind(-100, 50), buffer = 5000, debug = FALSE)$files
#expect_true(all(file.exists(f)))

#for (i in seq_along(f)) {
#expect_equal(c(256L, 256L, 3L), dim(raster_brick(f[i])))
#}
#fs <- list.files(dir, recursive = TRUE, full.names = TRUE)
#im <- cc_location(cbind(0, 0), debug = TRUE)
#fs <- list.files(dir, recursive = TRUE, full.names = TRUE)
#expect_true(all(file.remove(fs)))

})
12 changes: 9 additions & 3 deletions tests/testthat/test-loc-sanity.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ rpt <- cbind(147, -42)
ex <- ext(rep(rpt, each = 2L) + c(-2, 2, -3, 3))
dm <- function() sample(3:10, 2L)
test_that("raw loc works", {

skip_on_cran()
skip_if(is.null(get_api_key()))

expect_silent(cc_location(rpt, buffer = c(10, 0), dimension = dm(), verbose = TRUE))

## too many values, assumes first 2
Expand All @@ -21,7 +23,9 @@ test_that("raw loc works", {

test_that("Spatial loc works", {


skip_on_cran()
skip_if(is.null(get_api_key()))

## projected spdf, lines, points, mpoints
expect_s4_class(cc_location(ozdata$ll$sp, verbose = FALSE, dimension = dm(),), "SpatRaster")
expect_silent(cc_location(ozdata$proj$sp, dimension = dm(),))
Expand All @@ -37,7 +41,9 @@ test_that("Spatial loc works", {

test_that("Raster loc works", {


skip_on_cran()
skip_if(is.null(get_api_key()))

## projected raster, longlat raster
cc_location(ozdata$ll$raster, verbose = FALSE, dimension = dm())
cc_location(ozdata$proj$raster, verbose = FALSE, dimension = dm())
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-locations.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ context("test-locations")
dm <- function() sample(3:10, 2L)

test_that("built in locations works", {
skip_on_cran()
skip_if(is.null(get_api_key()))

expect_silent(lc <- cc_location(cbind(147, -42), buffer = 555, dimension = dm0 <- dm(), debug = TRUE))
expect_s4_class(lc, "SpatRaster")
Expand Down Expand Up @@ -31,7 +33,9 @@ test_that("built in locations works", {

test_that("max_tiles and zoom work", {


skip_on_cran()
skip_if(is.null(get_api_key()))


expect_message(cc_location(cbind(0, 0), max_tiles = 24, zoom = 5, dimension = dm()), "'zoom' and 'max_tiles' are ignored")

Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-tiles.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

test_that("tiles works", {
skip_on_cran()
skip_if(is.null(get_api_key()))

expect_message(rgb <- read_tiles(cbind(147, -42), buffer = 5000, max_tiles = 1, type = "mapbox.terrain-rgb"))
expect_silent(rng <- range(values(unpack_rgb(rgb))))
expect_true(rng[1] < 0)
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
context("test-utils")

test_that("utilities work as expected", {

skip_on_cran()
skip_if(is.null(get_api_key()))

expect_true(grepl("^https", token_url()))
expect_silent(instruct_on_key_creation())

Expand Down

0 comments on commit 4e46534

Please sign in to comment.