tests/testthat/test-esp-get-grid-MTN.R

test_that("Test offline", {
  skip_on_cran()
  skip_if_siane_offline()

  options(mapspain_test_offline = TRUE)
  expect_message(
    n <- esp_get_grid_MTN(update_cache = TRUE),
    "Offline"
  )
  expect_null(n)

  options(mapspain_test_offline = FALSE)
})

test_that("Test 404", {
  skip_on_cran()
  skip_if_siane_offline()

  options(mapspain_test_404 = TRUE)
  expect_message(
    n <- esp_get_grid_MTN(update_cache = TRUE),
    "Error"
  )
  expect_null(n)

  options(mapspain_test_404 = FALSE)
})


test_that("Errors", {
  expect_error(esp_get_grid_MTN("abcde"))
})


test_that("MTN grid online", {
  skip_on_cran()
  skip_if_siane_offline()
  tdir <- file.path(tempdir(), "testthat_test")
  tdir <- create_cache_dir(tdir)

  expect_message(
    esp_get_grid_MTN(
      cache_dir = tdir,
      verbose = TRUE
    )
  )

  unlink(tdir, recursive = TRUE, force = TRUE)
  expect_false(dir.exists(tdir))
})

Try the mapSpain package in your browser

Any scripts or data that you put into this service are public.

mapSpain documentation built on Jan. 17, 2026, 9:07 a.m.