Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip if offline, on cran #66

Merged
merged 2 commits into from
Sep 28, 2023
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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# terrainr (development version)

* More tests are flagged to skip on CRAN, or when run offline

* `georeference_overlay` should give fewer useless warnings

# terrainr 0.7.4

* New query method is dramatically faster and less-error prone.
Expand Down
2 changes: 1 addition & 1 deletion R/georeference_overlay.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ georeference_overlay <- function(overlay_file,

image_read <- switch(file_type,
"png" = png::readPNG,
"tiff" = tiff::readTIFF,
"tiff" = \(x) suppressWarnings(tiff::readTIFF(x)),
"jpeg" = jpeg::readJPEG
)

Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-2-get_tiles_3dep.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("get_tiles gets the same elevation tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down Expand Up @@ -56,6 +57,7 @@ test_that("get_tiles fails as expected", {

test_that("specifying SR works", {
skip_on_cran()
skip_if_offline()
dat <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-2-get_tiles_USGSHydroCached.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Disabled due to unreliable API endpoint
test_that("get_tiles gets the same topo tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-2-get_tiles_USGSImageryOnly.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Disabled due to unreliable API endpoint
test_that("get_tiles gets the same topo tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-2-get_tiles_USGSShadedReliefOnly.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Disabled due to unreliable API endpoint
test_that("get_tiles gets the same topo tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-2-get_tiles_USGSTNMBlank.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Disabled due to unreliable API endpoint
test_that("get_tiles gets the same topo tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-2-get_tiles_USGSTopo.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Disabled due to unreliable API endpoint
test_that("get_tiles gets the same topo tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-2-get_tiles_ecosystems.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("get_tiles gets the same ecosystems tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-2-get_tiles_geonames.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("get_tiles gets the same geonames tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-2-get_tiles_govunits.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("get_tiles gets the same govunits tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-2-get_tiles_nhd.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("get_tiles gets the same hydro tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-2-get_tiles_transportation.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("get_tiles gets the same transportation tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-2-get_tiles_wbd.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("get_tiles gets the same wbd tiles twice", {
skip_on_cran()
skip_if_offline()
dl_loc <- data.frame(
lat = c(44.04905, 44.04911),
lng = c(-74.01188, -74.01179)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-3-hit_api.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("dots replace their arguments", {
skip_on_cran()
skip_if_offline()
expect_equal(
hit_national_map_api(
list(
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-4-merge_rasters.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("merge_raster files are identical no matter the filename", {
skip_on_cran()
skip_if_offline()
df <- data.frame(
lat = c(44.050030001, 44.05003),
lng = c(-74.01164, -74.011640001)
Expand Down Expand Up @@ -43,6 +44,7 @@ test_that("merge_raster files are identical no matter the filename", {

test_that("fallback method works", {
skip_on_cran()
skip_if_offline()
# Just for time savings
skip_on_os(c("windows", "mac"))
df <- data.frame(
Expand Down Expand Up @@ -89,6 +91,7 @@ test_that("fallback method works", {

test_that("overwrite works as expected", {
skip_on_cran()
skip_if_offline()
test_file <- tempfile(fileext = ".tif")
test_copy <- tempfile(fileext = ".tif")

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-geom_spatial_rgb.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test_that("all methods of geom_spatial_rgb are equivalent", {
skip_on_cran()
skip_if_offline()
simulated_data <- data.frame(
id = seq(1, 100, 1),
lat = runif(100, 44.04905, 44.17609),
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-get_tiles.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Note: Individual data sources also have tests as test-2-get_tiles_<data>.R

test_that("SpatRast method is consistent", {
skip_on_cran()
skip_if_offline()
tmp_raster <- terra::rast("testdata/merge_rasters_test.tif")
rstr_tile <- get_tiles(tmp_raster, bboxSR = 4326, imageSR = 4326)
downloaded_raster <- terra::rast(rstr_tile[["elevation"]])
Expand All @@ -26,6 +28,7 @@ test_that("warnings fire appropriately", {

test_that("The deprecated list method still works", {
skip_on_cran()
skip_if_offline()
output_tif <- suppressWarnings(
get_tiles(list(
c(lat = 44.04905, lng = -74.01188),
Expand Down Expand Up @@ -58,6 +61,7 @@ test_that("The deprecated list method still works", {

test_that("projected returns are consistent", {
skip_on_cran()
skip_if_offline()
# For some reason, the exact boundaries appear to be system-specific
# They're very close across systems, but the API returns a slightly wider
# area for Mac and Windows than Linux
Expand Down
Loading