tests/testthat/test-nodes.r

context("nodes")

test_that("nodes", {
  vcr::use_cassette("nodes", {
    tt <- nodes()
    uu <- nodes(uuid="1193638d-32d1-43f0-a855-8727c94299d8")
    vv <- nodes(data='identifier', uuid="1193638d-32d1-43f0-a855-8727c94299d8")
  }, preserve_exact_body_bytes = TRUE)  

  expect_is(tt, "list")
  expect_is(tt$meta$limit, "integer")
  expect_is(tt$meta$endOfRecords, "logical")

  expect_is(uu, "list")
  expect_is(uu$data$country, "character")

  expect_is(vv, "list")
  expect_is(vv$data$createdBy, "character")

  # returns the correct value
  expect_equal(length(tt$data$tags[[1]]), 0)
  expect_equal(uu$data$title, "Republic of Congo")
  expect_equal(vv$data$key, 13587)
  expect_warning(vv$data$modifiedBy, "Unknown")

  # returns the correct dimensions
  expect_equal(length(tt), 2)
  expect_equal(NROW(tt$data), 100)
  expect_gt(length(uu$data), 3)
  expect_equal(length(vv), 2)
  expect_equal(length(vv$data), 5)
})

Try the rgbif package in your browser

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

rgbif documentation built on Sept. 11, 2023, 9:06 a.m.