Skip to content

Commit

Permalink
added tests for habitat params and output for name_lookup, fix #149
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Mar 24, 2015
1 parent af1c5d1 commit e3d8cf1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/testthat/test-name_lookup.r
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,21 @@ test_that("returns the correct dimensions", {

expect_equal(NCOL(uu), 35)
})

test_that("works with habitat parameter", {
# with facet
fachab <- name_lookup(facet='habitat', limit=0)
expect_equal(fachab$facets$habitat$name, c("MARINE", "TERRESTRIAL", "FRESHWATER"))

# with habitat parameter used
facet_terr <- name_lookup(habitat = "terrestrial", limit=2)
facet_mar <- name_lookup(habitat = "marine", limit=2)
facet_fresh <- name_lookup(habitat = "freshwater", limit=2)
expect_equal(facet_terr$data$habitats[1], "MARINE, TERRESTRIAL")
expect_equal(facet_mar$data$habitats[1], "MARINE, TERRESTRIAL")
expect_equal(facet_fresh$data$habitats[1], "FRESHWATER")

# another test
out <- name_lookup(query="Vulpes lagopus", rank="species", higherTaxonKey=5219234, habitat="terrestrial", return="data")
expect_equal(out$habitats, "MARINE, TERRESTRIAL")
})

0 comments on commit e3d8cf1

Please sign in to comment.