tests/testthat/test-as.gbif.R

skip_on_cran()

test_that("as.gbif", {
  vcr::use_cassette("as_gbif_prep", {
    spnames <- c('Accipiter striatus', 'Setophaga caerulescens',
      'Spinus tristis')
    out <- occ(query=spnames, from=c('gbif'), 
      gbifopts=list(hasCoordinate=TRUE), limit=2)
  }, preserve_exact_body_bytes = TRUE)

  vcr::use_cassette("as_gbif", {
    tt <- as.gbif(out)
  }, preserve_exact_body_bytes = TRUE)
  
  expect_is(tt, "list")
  expect_length(tt, 6)
  expect_match(names(tt), "[0-9]+")
  expect_is(tt[[1]], "gbifkey")
  expect_is(unclass(tt[[1]]), "list")
  expect_is(tt[[1]][[1]]$hierarchy, "data.frame")
  expect_is(tt[[1]][[1]]$media, "list")
  expect_is(tt[[1]][[1]]$data, "data.frame")
  expect_is(tt[[1]][[1]]$data$scientificName, "character")
})

Try the spocc package in your browser

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

spocc documentation built on March 31, 2023, 9:59 p.m.