Skip to content

Commit

Permalink
added some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Dec 1, 2015
1 parent 999d52c commit 78f7e78
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/bigsearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#'
Expand Down
12 changes: 7 additions & 5 deletions R/vert_id.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test-dump.R
Original file line number Diff line number Diff line change
@@ -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))
})
34 changes: 34 additions & 0 deletions tests/testthat/test-vert_id.R
Original file line number Diff line number Diff line change
@@ -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)))
})

0 comments on commit 78f7e78

Please sign in to comment.