From 25c62328b558de3d6e6ba4ca5890cebd21b11a50 Mon Sep 17 00:00:00 2001 From: 16EAGLE Date: Tue, 16 Apr 2024 11:09:50 +0200 Subject: [PATCH] updated tests to reflect recent changes --- DESCRIPTION | 2 +- NEWS.md | 2 +- man/basemap.Rd | 2 +- tests/testthat/test-basemap.R | 11 +++++++++++ tests/testthat/test-plot.R | 2 ++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bc5e3d4..99da877 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -4,7 +4,7 @@ Title: Accessing Spatial Basemaps in R Version: 0.0.7 Depends: R (>= 3.5.0) -Date: 2024-04-05 +Date: 2024-04-16 Authors@R: person("Jakob", "Schwalb-Willmann", email = "dev@schwalb-willmann.de", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2665-1509")) Description: A lightweight package to access spatial basemaps from open sources such as 'OpenStreetMap', 'Carto', 'Mapbox' and others in R. diff --git a/NEWS.md b/NEWS.md index 63900f9..d9e4e2d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ *** -## basemaps 0.0.6 +## basemaps 0.0.7 Minor improvements **Changes:** diff --git a/man/basemap.Rd b/man/basemap.Rd index 1d6b893..034e2a9 100644 --- a/man/basemap.Rd +++ b/man/basemap.Rd @@ -169,7 +169,7 @@ basemap_mapview( \item \code{browse}, logical, for \code{class = "png"} and interactive sessions only. Whether to open the png file in the system's default PNG viewer or not. Default is \code{TRUE}. \item \code{col}, character vector of colours for transforming single-layer basemaps into RGB, if \code{class = "png"} or \code{class = "magick"}. Default is \code{topo.colors(25)}. \item \code{dpi}, numeric vector of length 1 or 2 specifying the resolution of the image in DPI (dots per inch) for x and y (in that order) - it is recycled to length 2. - \item etc. (see ?gg_raster for valid arguments when using \code{class = "gglayer"} or \code{class = "ggplot"}, incuding maxpixels to control resolution of ggplot outputs + \item etc. (see \code{?gg_raster} for valid arguments when using \code{class = "gglayer"} or \code{class = "ggplot"}, including \code{maxpixels} to control resolution of ggplot outputs }} \item{verbose}{logical, if \code{TRUE}, messages and progress information are displayed on the console (default).} diff --git a/tests/testthat/test-basemap.R b/tests/testthat/test-basemap.R index 144fd0a..2d209f4 100644 --- a/tests/testthat/test-basemap.R +++ b/tests/testthat/test-basemap.R @@ -17,6 +17,8 @@ test_that("basemap()", { # test hiddena arguments expect_is(basemap(ext, no_transform = T, no_crop = T, verbose = F, class = "terra"), "SpatRaster") + expect_is(basemap(ext, no_transform = T, no_crop = T, verbose = F, class = "terra", col = topo.colors(22)), "SpatRaster") + expect_is(basemap(ext, no_transform = T, no_crop = T, verbose = F, class = "png", dpi = 100, browse = F), "character") # test warning with false map_dir expect_warning(basemap_plot(ext, map_dir = "/this/is/nonsense/", verbose = F)) @@ -24,6 +26,15 @@ test_that("basemap()", { # test ext error expect_error(basemap()) + # test no map_token error mapbox + expect_error(basemap(ext, map_service = "mapbox", map_type = "streets", verbose = F)) + expect_error(basemap(ext, map_service = "osm_thunderforest", map_type = "cycle", verbose = F)) + expect_error(basemap(ext, map_service = "osm_stamen", map_type = "toner", verbose = F)) + expect_error(basemap(ext, map_service = "osm_stadia", map_type = "alidade_smooth", verbose = F)) + + # test false map_token error mapbox + expect_error(basemap(ext, map_service = "mapbox", map_type = "streets", map_token = "this_is_nonsense", verbose = F)) + # test ext warning on different CRS expect_warning(basemap(ext_eur, map_dir = map_dir, verbose = T)) diff --git a/tests/testthat/test-plot.R b/tests/testthat/test-plot.R index 53cd66a..2bf4590 100644 --- a/tests/testthat/test-plot.R +++ b/tests/testthat/test-plot.R @@ -4,6 +4,8 @@ context("plot") test_that("gg_raster()", { map <- basemap_raster(ext, map_dir = map_dir, verbose = F) expect_is(gg_raster(map, r_type = "RGB"), "gg") + expect_is(gg_raster(map, r_type = "RGB", maxpixels = 500000, alpha = 0.5, interpolate = FALSE, add_coord = F), "gg") + expect_is(gg_raster(map, r_type = "RGB", gglayer = F), "gg") map <- basemap_stars(ext, map_dir = map_dir, verbose = F)