Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Aug 26, 2024
1 parent e17a5e0 commit 23cafb6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 40 deletions.
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
"applicationCategory": "cartography",
"isPartOf": "https://ropenspain.es/",
"keywords": ["rOpenSpain", "tiles", "r", "maps", "spatial", "rstats", "r-package", "municipalities", "Spain", "gisco", "provinces", "ign", "administrative-boundaries", "ccaa", "static-tiles", "spain", "cran", "ropenspain", "ggplot2", "gis"],
"fileSize": "2437.14KB",
"fileSize": "2436.708KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down
Binary file added tests/testthat/_snaps/esp_getTiles/opaque.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/testthat/_snaps/esp_getTiles/transp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 36 additions & 38 deletions tests/testthat/test-esp_getTiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,14 @@ test_that("tiles online", {
type = "IGNBase.Orto"
))

# No working well
#
# expect_message(esp_getTiles(poly,
# type = "RedTransporte.Carreteras",
# verbose = TRUE, mask = TRUE
# ))
# expect_message(esp_getTiles(poly,
# type = "RedTransporte.Carreteras",
# verbose = TRUE, mask = TRUE
# ))
expect_message(esp_getTiles(poly,
type = "PNOA",
verbose = TRUE, mask = TRUE
))
expect_message(esp_getTiles(poly,
type = "PNOA",
verbose = TRUE, mask = TRUE
))


# Try with jpg
Expand All @@ -116,19 +114,19 @@ test_that("tiles online", {
expect_s4_class(s, "SpatRaster")

# Check layers
# n <- expect_silent(esp_getTiles(poly,
# type = "RedTransporte.Carreteras"
# ))
#
#
# expect_equal(terra::nlyr(n), 4)
#
# opaque <- expect_silent(esp_getTiles(poly,
# type = "RedTransporte.Carreteras",
# transparent = FALSE
# ))

# expect_equal(terra::nlyr(opaque), 3)
n <- expect_silent(esp_getTiles(poly,
type = "Catastro"
))


expect_equal(terra::nlyr(n), 4)

opaque <- expect_silent(esp_getTiles(poly,
type = "Catastro",
transparent = FALSE
))

expect_equal(terra::nlyr(opaque), 3)

# Run only locally
skip_on_ci()
Expand All @@ -154,8 +152,8 @@ test_that("tiles online", {



# expect_snapshot_file(save_png(opaque), "opaque.png")
# expect_snapshot_file(save_png(n), "transp.png")
expect_snapshot_file(save_png(opaque), "opaque.png")
expect_snapshot_file(save_png(n), "transp.png")
expect_snapshot_file(save_png(s), "silent.png")
expect_snapshot_file(save_png(p), "point.png")
expect_snapshot_file(save_png(sfc), "sfc.png")
Expand Down Expand Up @@ -207,19 +205,19 @@ test_that("tiles options", {
skip_on_cran()
skip_if_offline()

poly <- esp_get_capimun(munic = "^Toledo", epsg = 3857)
poly <- sf::st_buffer(poly, 20)

# tile2 <- esp_getTiles(poly,
# type = "RedTransporte.Carreteras",
# options = list(
# version = "1.3.0",
# crs = "EPSG:25830",
# format = "image/jpeg"
# )
# )
#
# expect_s4_class(tile2, "SpatRaster")
poly <- esp_get_capimun(munic = "^Santiago de compos", epsg = 3857)
poly <- sf::st_buffer(poly, 2000)

tile2 <- esp_getTiles(poly,
type = "CaminoDeSantiago",
options = list(
version = "1.3.0",
crs = "EPSG:25830",
format = "image/jpeg"
)
)

expect_s4_class(tile2, "SpatRaster")

# Known problem on SSH certificate of catastro on ci
skip_on_ci()
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-esp_get_munic.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ test_that("munic local", {
skip_if_gisco_offline()

expect_silent(esp_get_munic(year = 2013, region = "Alava"))
expect_silent(esp_get_munic(year = 2017, region = "Alava"))
a2 <- esp_get_munic(year = 2018, region = "Alava")
expect_s3_class(a2, "sf")
})

# SIANE
Expand Down

0 comments on commit 23cafb6

Please sign in to comment.