You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
opensensmapR/tests/testthat/test_box.R

31 lines
620 B
R

context("box")
check_api <- function() {
code <- NA
try(code <- httr::status_code(httr::GET(osem_endpoint())))
if (is.na(code)) skip("API not available")
}
try({
boxes <- osem_boxes()
})
test_that("a box can be converted to sf object", {
check_api()
box <- osem_box(boxes$X_id[[1]])
box_sf <- sf::st_as_sf(box)
expect_true(sf::st_is_simple(box_sf))
expect_true("sf" %in% class(box_sf))
})
test_that("a box converted to sf object keeps all attributes", {
check_api()
box <- osem_box(boxes$X_id[[1]])
box_sf <- sf::st_as_sf(box)
expect_true(all(names(box) %in% names(box_sf)))
})