diff --git a/DESCRIPTION b/DESCRIPTION index a4105f0..d9d8b47 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: robis Title: Ocean Biogeographic Information System (OBIS) Client Description: Client for the Ocean Biogeographic Information System (). -Version: 2.1.10 -Date: 2019-06-17 +Version: 2.1.11 +Date: 2019-07-01 Authors@R: c( person("Pieter", "Provoost", , "pieterprovoost@gmail.com", c("cre", "aut")), person("Samuel", "Bosch", , "mail@samuelbosch.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 3b36863..2b6651e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# robis 2.1.11 + +Bugfix for checklist of unknown taxon. + # robis 2.1.10 Added hab parameter for IOC-UNESCO HAB species. diff --git a/R/checklist.R b/R/checklist.R index a3e13a1..1eea3ee 100644 --- a/R/checklist.R +++ b/R/checklist.R @@ -77,7 +77,7 @@ checklist <- function( res <- fromJSON(text, simplifyVector = TRUE) total <- res$total partition = partition + 1 - if (partition >= res$partitions) { + if (!("partitions" %in% names(res)) || partition >= res$partitions) { last_page <- TRUE } diff --git a/tests/testthat/test_checklist.R b/tests/testthat/test_checklist.R index 304500a..9dbde4c 100644 --- a/tests/testthat/test_checklist.R +++ b/tests/testthat/test_checklist.R @@ -5,6 +5,7 @@ family <- "Pectinariidae" family_taxa_lower_limit <- 10 family_taxa_upper_limit <- 1000 redlist_area <- 21 +unknown_aphiaid <- 999999999 test_that("scientificname restricts the checklist by scientificname", { taxa <- checklist(scientificname = family, verbose = TRUE) @@ -17,3 +18,9 @@ test_that("checklist only returns taxa with IUCN Red List category when redlist taxa <- checklist(areaid = redlist_area, redlist = TRUE, verbose = TRUE) expect_true(all(!is.na(taxa$category))) }) + +test_that("checklist for an unknown Aphia ID is empty", { + taxa <- checklist(taxonid = unknown_aphiaid) + expect_true(is.data.frame(taxa)) + expect_true(nrow(taxa) == 0) +})