diff --git a/R/bigsearch.R b/R/bigsearch.R index a4adabc..788a4ae 100644 --- a/R/bigsearch.R +++ b/R/bigsearch.R @@ -15,7 +15,7 @@ #' when your records are ready for download. #' #' @section Reading data: -#' We suggest reading data data in with \code{\link[data.table]{fread}} - as it's +#' We suggest reading data in with \code{\link[data.table]{fread}} - as it's #' very fast for the sometimes large datasets you will get from using this function, #' and is usually robust to formatting issues. #' diff --git a/R/vert_id.R b/R/vert_id.R index 190f752..b7005b3 100644 --- a/R/vert_id.R +++ b/R/vert_id.R @@ -1,19 +1,21 @@ #' Search by Vertnet occurrence ID #' #' @export -#' #' @param ids (character) VertNet IDs, one or more. Required. -#' @param compact (logical) Return a compact data frame. Default: \code{TRUE} +#' @param compact (logical) Return a compact data frame. That is, remove +#' empty columns. Default: \code{TRUE} #' @param verbose (logical) Print progress and information messages. Default: \code{TRUE} #' @param ... Curl arguments passed on to \code{\link[httr]{GET}} #' #' @return A list, with data frame of search results, and list of metadata #' @references \url{http://bit.ly/vertnet-wiki} +#' @details VertNet IDs can be a variety of things, some URIs (i.e., with http://...), +#' while others start with \code{urn}. #' #' @examples \dontrun{ -#' vert_id(ids = "urn:occurrence:Arctos:CUMV:Amph:10008:2243441") -#' ids <- c("urn:occurrence:Arctos:CUMV:Amph:10008:2243441", -#' "urn:occurrence:Arctos:CUMV:Fish:65813:2206324", +#' vert_id(ids = "urn:catalog:AUM:Fish:13271") +#' ids <- c("http://arctos.database.museum/guid/MSB:Mamm:56979?seid=1643089", +#' "urn:catalog:CM:Herps:116520", #' "urn:catalog:AUM:Fish:13271") #' res <- vert_id(ids) #' res$data$occurrenceid diff --git a/tests/testthat/test-dump.R b/tests/testthat/test-dump.R new file mode 100644 index 0000000..f7c6b2b --- /dev/null +++ b/tests/testthat/test-dump.R @@ -0,0 +1,16 @@ +context("dump") + +test_that("dump_links works", { + skip_on_cran() + + aa <- dump_links() + expect_is(aa, "list") + expect_is(aa$mammals, "list") + expect_is(aa$reptiles, "list") + expect_is(aa$amphibians, "list") + expect_is(aa$fishes, "list") + expect_is(aa$birds, "list") + expect_named(aa, c('mammals','reptiles','amphibians','fishes','birds')) + expect_true(grepl("https", aa$mammals$view)) + expect_true(grepl("urn:uuid", aa$fishes$data)) +}) diff --git a/tests/testthat/test-vert_id.R b/tests/testthat/test-vert_id.R new file mode 100644 index 0000000..be4ecc6 --- /dev/null +++ b/tests/testthat/test-vert_id.R @@ -0,0 +1,34 @@ +context("vert_id") + +test_that("vert_id works", { + skip_on_cran() + + aa <- vert_id(ids = "urn:catalog:AUM:Fish:13271", verbose = FALSE) + + expect_is(aa, "list") + expect_is(aa$meta, "list") + expect_is(aa$data, "data.frame") + expect_equal(NROW(aa$data), 1) + expect_named(aa$meta, c('request_date','response_records','request_origin','last_cursor', + 'limit','query_version','matching_records','api_version')) + expect_true(grepl("Noturus", aa$data$scientificname)) +}) + +test_that("vert_id works", { + skip_on_cran() + + ids <- c("http://arctos.database.museum/guid/MSB:Mamm:56979?seid=1643089", + "urn:catalog:CM:Herps:116520", + "urn:catalog:AUM:Fish:13271") + aa <- vert_id(ids, verbose = FALSE) + + expect_is(aa, "list") + expect_is(aa$meta, "list") + expect_is(aa$data, "data.frame") + expect_equal(NROW(aa$data), 3) + expect_named(aa$meta, c('request_date','response_records','request_origin','last_cursor', + 'limit','query_version','matching_records','api_version')) + expect_true(any(grepl("Noturus", aa$data$scientificname))) + expect_true(any(grepl("Zapus", aa$data$scientificname))) + expect_true(any(grepl("Bufo", aa$data$scientificname))) +})