Running ‘test-all.R’ [6s/31s]
Running the tests in ‘tests/test-all.R’ failed.
Complete output:
  > library(testthat)
  > library(rcites)
  > library(tibble)
  > test_check("rcites")
  v Token stored for the session.
  [ FAIL 28 | WARN 15 | SKIP 5 | PASS 42 ]
  
  ══ Skipped tests (5) ═══════════════════════════════════════════════════════════
  • On CRAN (5): 'test-distributions.R:13:5', 'test-distributions.R:20:5',
    'test-legislations.R:16:5', 'test-references.R:11:3', 'test-token.R:9:5'
  
  ══ Failed tests ════════════════════════════════════════════════════════════════
  ── Failure ('test-distributions.R:11:5'): spp_distributions() defaults work ────
  all(unlist(lapply(res, function(x) is_cl_df(x)))) is not TRUE
  
  `actual`:   FALSE
  `expected`: TRUE 
  ── Failure ('test-distributions.R:12:5'): spp_distributions() defaults work ────
  lang_GQ %in% res$distributions$name (`actual`) not identical to c(TRUE, FALSE, FALSE) (`expected`).
  
  `actual`:   FALSE FALSE FALSE
  `expected`: TRUE  FALSE FALSE
  ── Failure ('test-distributions.R:18:7'): spp_distributions() works when no info available ──
  `res <- spp_distributions(taxon_id = 0)` did not throw the expected warning.
  Backtrace:
      ▆
   1. ├─vcr::use_cassette(...) at test-distributions.R:17:5
   2. │ └─cassette$call_block(...)
   3. └─testthat::expect_warning(res <- spp_distributions(taxon_id = 0)) at test-distributions.R:18:7
  ── Error ('test-distributions.R:25:7'): spp_distributions() raw mode works ─────
  Error in `class(out) <- c("list", "spp_raw")`: attempt to set an attribute on NULL
  Backtrace:
       ▆
    1. ├─vcr::use_cassette(...) at test-distributions.R:24:5
    2. │ └─cassette$call_block(...)
    3. ├─testthat::expect_silent(...) at test-distributions.R:25:7
    4. │ └─testthat:::quasi_capture(enquo(object), NULL, evaluate_promise)
    5. │   ├─testthat (local) .capture(...)
    6. │   │ ├─withr::with_output_sink(...)
    7. │   │ │ └─base::force(code)
    8. │   │ ├─base::withCallingHandlers(...)
    9. │   │ └─base::withVisible(code)
   10. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   11. └─rcites::spp_distributions(taxon_id = tx_id, raw = TRUE, verbose = FALSE)
  ── Failure ('test-distributions.R:44:5'): spp_distributions() language works ───
  lang_GQ %in% res1$distributions$name (`actual`) not identical to c(FALSE, TRUE, FALSE) (`expected`).
  
  `actual`:   FALSE FALSE FALSE
  `expected`: FALSE TRUE  FALSE
  ── Error ('test-distributions.R:50:7'): spp_distributions() batch mode works ───
  Error in `class(out) <- c("list", "spp_raw")`: attempt to set an attribute on NULL
  Backtrace:
      ▆
   1. ├─vcr::use_cassette(...) at test-distributions.R:48:5
   2. │ └─cassette$call_block(...)
   3. └─rcites::spp_distributions(...) at test-distributions.R:50:7
   4.   └─base::lapply(...)
   5.     └─rcites (local) FUN(X[[i]], ...)
  ── Failure ('test-distributions.R:67:5'): spp_distributions() edge case: one distribution ──
  dim(res$distribution)[1] (`actual`) not equal to 1 (`expected`).
  
    `actual`: 0.0
  `expected`: 1.0
  ── Failure ('test-legislations.R:13:5'): spp_cites_legislation() defaults work ──
  res$cites_suspensions$applies_to_import has type 'NULL', not 'logical'.
  ── Failure ('test-legislations.R:14:5'): spp_cites_legislation() defaults work ──
  res$cites_quotas$public_display has type 'NULL', not 'logical'.
  ── Failure ('test-legislations.R:15:5'): spp_cites_legislation() defaults work ──
  "Guinea" %in% res$cites_suspensions$geo_entity.name is not TRUE
  
  `actual`:   FALSE
  `expected`: TRUE 
  ── Error ('test-legislations.R:21:7'): spp_cites_legislation() raw mode works ──
  Error in `class(out) <- c("list", "spp_raw")`: attempt to set an attribute on NULL
  Backtrace:
       ▆
    1. ├─vcr::use_cassette(...) at test-legislations.R:20:5
    2. │ └─cassette$call_block(...)
    3. ├─testthat::expect_silent(...) at test-legislations.R:21:7
    4. │ └─testthat:::quasi_capture(enquo(object), NULL, evaluate_promise)
    5. │   ├─testthat (local) .capture(...)
    6. │   │ ├─withr::with_output_sink(...)
    7. │   │ │ └─base::force(code)
    8. │   │ ├─base::withCallingHandlers(...)
    9. │   │ └─base::withVisible(code)
   10. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   11. └─rcites::spp_cites_legislation(taxon_id = tx_id, raw = TRUE, verbose = FALSE)
  ── Failure ('test-legislations.R:46:5'): spp_cites_legislation() scope & language works ──
  !all(res$cites_listings$is_current) is not TRUE
  
  `actual`:   FALSE
  `expected`: TRUE 
  ── Failure ('test-legislations.R:47:5'): spp_cites_legislation() scope & language works ──
  "Guinée" %in% res$cites_suspensions$geo_entity.name is not TRUE
  
  `actual`:   FALSE
  `expected`: TRUE 
  ── Failure ('test-legislations.R:54:5'): spp_eu_legislation() defaults works ───
  nrow(res$eu_listings) (`actual`) not equal to 2 (`expected`).
  
    `actual`: 0.0
  `expected`: 2.0
  ── Failure ('test-legislations.R:55:5'): spp_eu_legislation() defaults works ───
  "Namibia" %in% res$eu_decisions$geo_entity.name is not TRUE
  
  `actual`:   FALSE
  `expected`: TRUE 
  ── Error ('test-legislations.R:64:7'): spp_eu_legislation() raw mode works ─────
  Error in `class(out) <- c("list", "spp_raw")`: attempt to set an attribute on NULL
  Backtrace:
       ▆
    1. ├─vcr::use_cassette(...) at test-legislations.R:63:5
    2. │ └─cassette$call_block(...)
    3. ├─testthat::expect_silent(...) at test-legislations.R:64:7
    4. │ └─testthat:::quasi_capture(enquo(object), NULL, evaluate_promise)
    5. │   ├─testthat (local) .capture(...)
    6. │   │ ├─withr::with_output_sink(...)
    7. │   │ │ └─base::force(code)
    8. │   │ ├─base::withCallingHandlers(...)
    9. │   │ └─base::withVisible(code)
   10. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   11. └─rcites::spp_eu_legislation(taxon_id = tx_id, raw = TRUE, verbose = FALSE)
  ── Failure ('test-legislations.R:89:5'): spp_cites_legislation() scope & lang works ──
  !all(res$eu_listings$is_current) is not TRUE
  
  `actual`:   FALSE
  `expected`: TRUE 
  ── Failure ('test-legislations.R:90:5'): spp_cites_legislation() scope & lang works ──
  "Namibie" %in% res$eu_decisions$geo_entity.name is not TRUE
  
  `actual`:   FALSE
  `expected`: TRUE 
  ── Failure ('test-legislations.R:102:5'): spp_cites_legislation() batch mode works ──
  unique(res$cites_listings$taxon_id) (`actual`) not identical to c(tx_id, tx_id2) (`expected`).
  
  `actual` is NULL
  `expected` is a character vector ('4521', '3210')
  ── Failure ('test-legislations.R:119:5'): spp_cites_legislation() batch mode works ──
  unique(res$eu_listings$taxon_id) (`actual`) not identical to c(tx_id, tx_id2) (`expected`).
  
  `actual` is NULL
  `expected` is a character vector ('4521', '3210')
  ── Error ('test-references.R:16:5'): spp_references() raw mode ─────────────────
  Error in `class(out) <- c("list", "spp_raw")`: attempt to set an attribute on NULL
  Backtrace:
       ▆
    1. ├─vcr::use_cassette(...) at test-references.R:15:3
    2. │ └─cassette$call_block(...)
    3. ├─testthat::expect_silent(...) at test-references.R:16:5
    4. │ └─testthat:::quasi_capture(enquo(object), NULL, evaluate_promise)
    5. │   ├─testthat (local) .capture(...)
    6. │   │ ├─withr::with_output_sink(...)
    7. │   │ │ └─base::force(code)
    8. │   │ ├─base::withCallingHandlers(...)
    9. │   │ └─base::withVisible(code)
   10. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   11. └─rcites::spp_references(taxon_id = tx_id, raw = TRUE, verbose = FALSE)
  ── Failure ('test-references.R:40:3'): spp_references() batch mode works ───────
  unique(res$references$taxon_id) (`actual`) not identical to c(tx_id, tx_id2) (`expected`).
  
  `actual` is NULL
  `expected` is a character vector ('4521', '3210')
  ── Error ('test-references.R:45:5'): spp_references() raw batch mode works ─────
  Error in `class(out) <- c("list", "spp_raw")`: attempt to set an attribute on NULL
  Backtrace:
      ▆
   1. ├─vcr::use_cassette(...) at test-references.R:44:3
   2. │ └─cassette$call_block(...)
   3. └─rcites::spp_references(...) at test-references.R:45:5
   4.   └─base::lapply(...)
   5.     └─rcites (local) FUN(X[[i]], ...)
  ── Error ('test-taxonconcept.R:12:5'): spp_taxonconcept() defaults work ────────
  Error in `if (!pag) {
      warning("Taxon not listed.")
      return(NULL)
  } else {
      if (pag > 1) {
          if (is.null(pages)) 
              pages <- seq_len(pag)
          else pages <- pages[pages <= pag]
          if (!length(pages)) 
              stop("Only page 1-", pag, " are available.")
          if (length(pages) > 1) {
              res <- rcites_autopagination(q_url, per_page, pages[-1L], 
                  pag, token, verbose, ...)
              tmp2 <- c(tmp$taxon_concepts, do.call(c, lapply(res, 
                  function(x) x$taxon_concepts)))
          }
          else tmp2 <- tmp$taxon_concepts
      }
      else tmp2 <- tmp$taxon_concepts
      if (raw) {
          class(tmp2) <- c("list", "spp_raw")
          return(tmp2)
      }
      else {
          sp_nm <- c("synonyms", "higher_taxa", "common_names", 
              "cites_listing", "cites_listings", "accepted_names")
          out <- list()
          out$all_id <- rcites_taxonconcept_allentries(tmp2, sp_nm)
          out$all_id$updated_at <- as.POSIXlt(out$all_id$updated_at, 
              format = "%Y-%m-%dT%H:%M:%OS")
          out$all_id$active <- as.logical(out$all_id$active)
          id <- which(out$all_id$active)
          out$general <- out$all_id[out$all_id$active, ]
          out$higher_taxa <- rcites_taxonconcept_higher_taxa(tmp2[id], 
              out$general$id)
          out$accepted_names <- rcites_taxonconcept_names(tmp2[!id], 
              "accepted_names", out$all_id$id[!id])
          out$common_names <- rcites_taxonconcept_names(tmp2[id], 
              "common_names", out$general$id)
          out$synonyms <- rcites_taxonconcept_names(tmp2[id], "synonyms", 
              out$general$id)
          if (taxonomy == "CITES") {
              tmp_cit <- lapply(tmp2[id], function(x) x$cites_listing)
              out$general$cites_listing <- unlist(lapply(tmp_cit, 
                  rcites_null_to_na))
              out$cites_listings <- rcites_taxonconcept_cites_listings(tmp2[id], 
                  out$general$id)
          }
          class(out$general) <- class(out$all_id) <- c("tbl_df", 
              "tbl", "data.frame")
          class(out) <- c("spp_taxon")
          attr(out, "taxonomy") <- taxonomy
      }
  }`: argument is of length zero
  Backtrace:
      ▆
   1. ├─vcr::use_cassette(...) at test-taxonconcept.R:11:3
   2. │ └─cassette$call_block(...)
   3. ├─base::suppressMessages(res <- spp_taxonconcept(query_taxon = tx_nm)) at test-taxonconcept.R:12:5
   4. │ └─base::withCallingHandlers(...)
   5. └─rcites::spp_taxonconcept(query_taxon = tx_nm)
  ── Error ('test-taxonconcept.R:29:7'): spp_taxonconcept() raw mode works ───────
  Error in `if (!pag) {
      warning("Taxon not listed.")
      return(NULL)
  } else {
      if (pag > 1) {
          if (is.null(pages)) 
              pages <- seq_len(pag)
          else pages <- pages[pages <= pag]
          if (!length(pages)) 
              stop("Only page 1-", pag, " are available.")
          if (length(pages) > 1) {
              res <- rcites_autopagination(q_url, per_page, pages[-1L], 
                  pag, token, verbose, ...)
              tmp2 <- c(tmp$taxon_concepts, do.call(c, lapply(res, 
                  function(x) x$taxon_concepts)))
          }
          else tmp2 <- tmp$taxon_concepts
      }
      else tmp2 <- tmp$taxon_concepts
      if (raw) {
          class(tmp2) <- c("list", "spp_raw")
          return(tmp2)
      }
      else {
          sp_nm <- c("synonyms", "higher_taxa", "common_names", 
              "cites_listing", "cites_listings", "accepted_names")
          out <- list()
          out$all_id <- rcites_taxonconcept_allentries(tmp2, sp_nm)
          out$all_id$updated_at <- as.POSIXlt(out$all_id$updated_at, 
              format = "%Y-%m-%dT%H:%M:%OS")
          out$all_id$active <- as.logical(out$all_id$active)
          id <- which(out$all_id$active)
          out$general <- out$all_id[out$all_id$active, ]
          out$higher_taxa <- rcites_taxonconcept_higher_taxa(tmp2[id], 
              out$general$id)
          out$accepted_names <- rcites_taxonconcept_names(tmp2[!id], 
              "accepted_names", out$all_id$id[!id])
          out$common_names <- rcites_taxonconcept_names(tmp2[id], 
              "common_names", out$general$id)
          out$synonyms <- rcites_taxonconcept_names(tmp2[id], "synonyms", 
              out$general$id)
          if (taxonomy == "CITES") {
              tmp_cit <- lapply(tmp2[id], function(x) x$cites_listing)
              out$general$cites_listing <- unlist(lapply(tmp_cit, 
                  rcites_null_to_na))
              out$cites_listings <- rcites_taxonconcept_cites_listings(tmp2[id], 
                  out$general$id)
          }
          class(out$general) <- class(out$all_id) <- c("tbl_df", 
              "tbl", "data.frame")
          class(out) <- c("spp_taxon")
          attr(out, "taxonomy") <- taxonomy
      }
  }`: argument is of length zero
  Backtrace:
       ▆
    1. ├─vcr::use_cassette(...) at test-taxonconcept.R:28:5
    2. │ └─cassette$call_block(...)
    3. ├─testthat::expect_silent(...) at test-taxonconcept.R:29:7
    4. │ └─testthat:::quasi_capture(enquo(object), NULL, evaluate_promise)
    5. │   ├─testthat (local) .capture(...)
    6. │   │ ├─withr::with_output_sink(...)
    7. │   │ │ └─base::force(code)
    8. │   │ ├─base::withCallingHandlers(...)
    9. │   │ └─base::withVisible(code)
   10. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   11. └─rcites::spp_taxonconcept(query_taxon = tx_nm, raw = TRUE, verbose = FALSE)
  ── Error ('test-taxonconcept.R:43:7'): spp_taxonconcept() CMS works ────────────
  Error in `if (!pag) {
      warning("Taxon not listed.")
      return(NULL)
  } else {
      if (pag > 1) {
          if (is.null(pages)) 
              pages <- seq_len(pag)
          else pages <- pages[pages <= pag]
          if (!length(pages)) 
              stop("Only page 1-", pag, " are available.")
          if (length(pages) > 1) {
              res <- rcites_autopagination(q_url, per_page, pages[-1L], 
                  pag, token, verbose, ...)
              tmp2 <- c(tmp$taxon_concepts, do.call(c, lapply(res, 
                  function(x) x$taxon_concepts)))
          }
          else tmp2 <- tmp$taxon_concepts
      }
      else tmp2 <- tmp$taxon_concepts
      if (raw) {
          class(tmp2) <- c("list", "spp_raw")
          return(tmp2)
      }
      else {
          sp_nm <- c("synonyms", "higher_taxa", "common_names", 
              "cites_listing", "cites_listings", "accepted_names")
          out <- list()
          out$all_id <- rcites_taxonconcept_allentries(tmp2, sp_nm)
          out$all_id$updated_at <- as.POSIXlt(out$all_id$updated_at, 
              format = "%Y-%m-%dT%H:%M:%OS")
          out$all_id$active <- as.logical(out$all_id$active)
          id <- which(out$all_id$active)
          out$general <- out$all_id[out$all_id$active, ]
          out$higher_taxa <- rcites_taxonconcept_higher_taxa(tmp2[id], 
              out$general$id)
          out$accepted_names <- rcites_taxonconcept_names(tmp2[!id], 
              "accepted_names", out$all_id$id[!id])
          out$common_names <- rcites_taxonconcept_names(tmp2[id], 
              "common_names", out$general$id)
          out$synonyms <- rcites_taxonconcept_names(tmp2[id], "synonyms", 
              out$general$id)
          if (taxonomy == "CITES") {
              tmp_cit <- lapply(tmp2[id], function(x) x$cites_listing)
              out$general$cites_listing <- unlist(lapply(tmp_cit, 
                  rcites_null_to_na))
              out$cites_listings <- rcites_taxonconcept_cites_listings(tmp2[id], 
                  out$general$id)
          }
          class(out$general) <- class(out$all_id) <- c("tbl_df", 
              "tbl", "data.frame")
          class(out) <- c("spp_taxon")
          attr(out, "taxonomy") <- taxonomy
      }
  }`: argument is of length zero
  Backtrace:
      ▆
   1. ├─vcr::use_cassette(...) at test-taxonconcept.R:42:5
   2. │ └─cassette$call_block(...)
   3. └─rcites::spp_taxonconcept(...) at test-taxonconcept.R:43:7
  ── Error ('test-taxonconcept.R:54:7'): spp_taxonconcept() page selection works ──
  Error in `if (!pag) {
      warning("Taxon not listed.")
      return(NULL)
  } else {
      if (pag > 1) {
          if (is.null(pages)) 
              pages <- seq_len(pag)
          else pages <- pages[pages <= pag]
          if (!length(pages)) 
              stop("Only page 1-", pag, " are available.")
          if (length(pages) > 1) {
              res <- rcites_autopagination(q_url, per_page, pages[-1L], 
                  pag, token, verbose, ...)
              tmp2 <- c(tmp$taxon_concepts, do.call(c, lapply(res, 
                  function(x) x$taxon_concepts)))
          }
          else tmp2 <- tmp$taxon_concepts
      }
      else tmp2 <- tmp$taxon_concepts
      if (raw) {
          class(tmp2) <- c("list", "spp_raw")
          return(tmp2)
      }
      else {
          sp_nm <- c("synonyms", "higher_taxa", "common_names", 
              "cites_listing", "cites_listings", "accepted_names")
          out <- list()
          out$all_id <- rcites_taxonconcept_allentries(tmp2, sp_nm)
          out$all_id$updated_at <- as.POSIXlt(out$all_id$updated_at, 
              format = "%Y-%m-%dT%H:%M:%OS")
          out$all_id$active <- as.logical(out$all_id$active)
          id <- which(out$all_id$active)
          out$general <- out$all_id[out$all_id$active, ]
          out$higher_taxa <- rcites_taxonconcept_higher_taxa(tmp2[id], 
              out$general$id)
          out$accepted_names <- rcites_taxonconcept_names(tmp2[!id], 
              "accepted_names", out$all_id$id[!id])
          out$common_names <- rcites_taxonconcept_names(tmp2[id], 
              "common_names", out$general$id)
          out$synonyms <- rcites_taxonconcept_names(tmp2[id], "synonyms", 
              out$general$id)
          if (taxonomy == "CITES") {
              tmp_cit <- lapply(tmp2[id], function(x) x$cites_listing)
              out$general$cites_listing <- unlist(lapply(tmp_cit, 
                  rcites_null_to_na))
              out$cites_listings <- rcites_taxonconcept_cites_listings(tmp2[id], 
                  out$general$id)
          }
          class(out$general) <- class(out$all_id) <- c("tbl_df", 
              "tbl", "data.frame")
          class(out) <- c("spp_taxon")
          attr(out, "taxonomy") <- taxonomy
      }
  }`: argument is of length zero
  Backtrace:
      ▆
   1. ├─vcr::use_cassette(...) at test-taxonconcept.R:53:5
   2. │ └─cassette$call_block(...)
   3. └─rcites::spp_taxonconcept(...) at test-taxonconcept.R:54:7
  ── Error ('test-taxonconcept.R:66:5'): spp_taxonconcept() updated_since works ──
  Error in `if (!pag) {
      warning("Taxon not listed.")
      return(NULL)
  } else {
      if (pag > 1) {
          if (is.null(pages)) 
              pages <- seq_len(pag)
          else pages <- pages[pages <= pag]
          if (!length(pages)) 
              stop("Only page 1-", pag, " are available.")
          if (length(pages) > 1) {
              res <- rcites_autopagination(q_url, per_page, pages[-1L], 
                  pag, token, verbose, ...)
              tmp2 <- c(tmp$taxon_concepts, do.call(c, lapply(res, 
                  function(x) x$taxon_concepts)))
          }
          else tmp2 <- tmp$taxon_concepts
      }
      else tmp2 <- tmp$taxon_concepts
      if (raw) {
          class(tmp2) <- c("list", "spp_raw")
          return(tmp2)
      }
      else {
          sp_nm <- c("synonyms", "higher_taxa", "common_names", 
              "cites_listing", "cites_listings", "accepted_names")
          out <- list()
          out$all_id <- rcites_taxonconcept_allentries(tmp2, sp_nm)
          out$all_id$updated_at <- as.POSIXlt(out$all_id$updated_at, 
              format = "%Y-%m-%dT%H:%M:%OS")
          out$all_id$active <- as.logical(out$all_id$active)
          id <- which(out$all_id$active)
          out$general <- out$all_id[out$all_id$active, ]
          out$higher_taxa <- rcites_taxonconcept_higher_taxa(tmp2[id], 
              out$general$id)
          out$accepted_names <- rcites_taxonconcept_names(tmp2[!id], 
              "accepted_names", out$all_id$id[!id])
          out$common_names <- rcites_taxonconcept_names(tmp2[id], 
              "common_names", out$general$id)
          out$synonyms <- rcites_taxonconcept_names(tmp2[id], "synonyms", 
              out$general$id)
          if (taxonomy == "CITES") {
              tmp_cit <- lapply(tmp2[id], function(x) x$cites_listing)
              out$general$cites_listing <- unlist(lapply(tmp_cit, 
                  rcites_null_to_na))
              out$cites_listings <- rcites_taxonconcept_cites_listings(tmp2[id], 
                  out$general$id)
          }
          class(out$general) <- class(out$all_id) <- c("tbl_df", 
              "tbl", "data.frame")
          class(out) <- c("spp_taxon")
          attr(out, "taxonomy") <- taxonomy
      }
  }`: argument is of length zero
  Backtrace:
      ▆
   1. ├─vcr::use_cassette(...) at test-taxonconcept.R:65:3
   2. │ └─cassette$call_block(...)
   3. └─rcites::spp_taxonconcept(...) at test-taxonconcept.R:66:5
  
  [ FAIL 28 | WARN 15 | SKIP 5 | PASS 42 ]
  Error: Test failures
  Execution halted