Running ‘testthat.R’ [10s/28s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(traitdataform)
  > 
  > test_check("traitdataform")
  ── 1. Error: gbif taxonomy reachable (@test.map_gbif_taxonomy.R#11)  ───────────
  Service Unavailable (HTTP 503)
  1: expect_known_hash(get_gbif_taxonomy(as.character(arthropodtraits$SpeciesID[1:12])), 
         hash = "74f9a02a12") at testthat/test.map_gbif_taxonomy.R:11
  2: quasi_label(enquo(object))
  3: eval_bare(get_expr(quo), get_env(quo))
  4: get_gbif_taxonomy(as.character(arthropodtraits$SpeciesID[1:12]))
  5: taxize::get_gbifid_(x, messages = verbose)
  6: setNames(lapply(sciname, get_gbifd_help, messages = messages, rows = rows, method = method), 
         sciname)
  7: lapply(sciname, get_gbifd_help, messages = messages, rows = rows, method = method)
  8: FUN(X[[i]], ...)
  9: gbif_name_backbone(sciname)
  10: temp$raise_for_status()
  11: fauxpas::http(self, behavior = "stop")
  12: http.HttpResponse(self, behavior = "stop")
  13: tmp$do(response)
  
  ── 2. Error: mapping synonyms (@test.map_gbif_taxonomy.R#25)  ──────────────────
  Service Unavailable (HTTP 503)
  1: expect_true(get_gbif_taxonomy("Trichocellus_cognatus")$scientificNameStd == "Dicheirotrichus cognatus") at testthat/test.map_gbif_taxonomy.R:25
  2: quasi_label(enquo(object), label)
  3: eval_bare(get_expr(quo), get_env(quo))
  4: get_gbif_taxonomy("Trichocellus_cognatus")
  5: taxize::get_gbifid_(temp[[i]]$species[which.max(temp[[i]]$confidence)], messages = verbose)
  6: setNames(lapply(sciname, get_gbifd_help, messages = messages, rows = rows, method = method), 
         sciname)
  7: lapply(sciname, get_gbifd_help, messages = messages, rows = rows, method = method)
  8: FUN(X[[i]], ...)
  9: gbif_name_backbone(sciname)
  10: temp$raise_for_status()
  11: fauxpas::http(self, behavior = "stop")
  12: http.HttpResponse(self, behavior = "stop")
  13: tmp$do(response)
  
  ── 3. Error: not matching (@test.map_gbif_taxonomy.R#53)  ──────────────────────
  Service Unavailable (HTTP 503)
  1: expect_true(get_gbif_taxonomy("raoi_sdoi")$warnings == "No matching species concept! No match! Check spelling or lower confidence threshold!") at testthat/test.map_gbif_taxonomy.R:53
  2: quasi_label(enquo(object), label)
  3: eval_bare(get_expr(quo), get_env(quo))
  4: get_gbif_taxonomy("raoi_sdoi")
  5: taxize::get_gbifid_(x, messages = verbose)
  6: setNames(lapply(sciname, get_gbifd_help, messages = messages, rows = rows, method = method), 
         sciname)
  7: lapply(sciname, get_gbifd_help, messages = messages, rows = rows, method = method)
  8: FUN(X[[i]], ...)
  9: gbif_name_backbone(sciname)
  10: temp$raise_for_status()
  11: fauxpas::http(self, behavior = "stop")
  12: http.HttpResponse(self, behavior = "stop")
  13: tmp$do(response)
  
  ── 4. Error: mapping of taxa works (@test.standardize.R#21)  ───────────────────
  Service Unavailable (HTTP 503)
  1: standardise_taxa(dataset2[c(215, 476, 774, 975, 1445, 1706, 3437, 3905, 4667, 5396, 
         5896, 8755, 8966), ]) at testthat/test.standardize.R:21
  2: do.call(method, c(list(levels(droplevels(as.factor(x$scientificName)))), method_options))
  3: (function (x, subspecies = TRUE, higherrank = FALSE, verbose = FALSE, fuzzy = TRUE, 
         conf_threshold = 90, resolve_synonyms = TRUE) 
     {
         matchtype = status = confidence = NULL
         temp <- taxize::get_gbifid_(x, messages = verbose)
         for (i in 1:length(temp)) {
             warning_i = ""
             synonym_i = FALSE
             if (nrow(temp[[i]]) == 0) {
                 warning_i <- paste("No matching species concept!")
                 temp[[i]] <- data.frame(scientificName = x[i], matchtype = "NONE", status = "NA", 
                     rank = "species")
             }
             if (!fuzzy & nrow(temp[[i]]) > 0) {
                 temp[[i]] <- subset(temp[[i]], matchtype != "FUZZY")
                 if (nrow(temp[[i]]) == 0) {
                     warning_i <- paste(warning_i, "Fuzzy matching might yield results.")
                 }
             }
             if (!is.null(conf_threshold) & nrow(temp[[i]]) > 0) {
                 temp[[i]] <- subset(temp[[i]], confidence >= conf_threshold)
                 if (nrow(temp[[i]]) == 0) {
                     temp[[i]] <- data.frame(scientificName = x[i], matchtype = "NONE", 
                       status = "NA", rank = "species")
                     warning_i <- paste(warning_i, "No match! Check spelling or lower confidence threshold!")
                 }
             }
             if (any(temp[[i]]$status == "ACCEPTED")) {
                 temp[[i]] <- subset(temp[[i]], status == "ACCEPTED")
                 temp[[i]] <- subset(temp[[i]], temp[[i]]$confidence == max(temp[[i]]$confidence))
                 if (nrow(temp[[i]]) > 1) {
                     temp[[i]] <- temp[[i]][1, ]
                     warning_i <- paste(warning_i, "Selected first of multiple equally ranked concepts!")
                 }
             }
             if (!any(temp[[i]]$status == "ACCEPTED") & any(temp[[i]]$status == "SYNONYM")) {
                 if (resolve_synonyms) {
                     keep <- temp[i]
                     temp[i] <- taxize::get_gbifid_(temp[[i]]$species[which.max(temp[[i]]$confidence)], 
                       messages = verbose)
                     if (temp[[i]][1, ]$status == "ACCEPTED") {
                       temp[[i]] <- subset(temp[[i]], matchtype == "EXACT" & status == 
                         "ACCEPTED")
                       temp[[i]] <- subset(temp[[i]], temp[[i]]$confidence == max(temp[[i]]$confidence))
                       if (nrow(temp[[i]]) > 1) {
                         temp[[i]] <- temp[[i]][1, ]
                         warning_i <- paste(warning_i, "Selected first of multiple equally ranked concepts!")
                       }
                       warning_i <- paste(warning_i, "A synonym was mapped to the accepted species concept!", 
                         sep = " ")
                       synonym_i = TRUE
                     }
                     else {
                       status <- temp[[i]][1, ]$status
                       temp[i] <- keep
                       if (nrow(temp[[i]]) > 1) {
                         temp[[i]] <- temp[[i]][1, ]
                         warning_i <- paste(warning_i, "Selected first of multiple equally ranked concepts!")
                       }
                       warning_i <- paste0(warning_i, " Resolved synonym '", temp[[i]]$species, 
                         "' is labelled '", status, "'. Clarification required!")
                     }
                 }
                 else {
                     temp[[i]] <- subset(temp[[i]], status == "SYNONYM")
                     temp[[i]] <- subset(temp[[i]], temp[[i]]$confidence == max(temp[[i]]$confidence))
                     warning_i <- paste(warning_i, "The provided taxon seems to be a synonym of '", 
                       temp[[i]]$species, "'!", sep = "")
                 }
             }
             if (all(temp[[i]]$status == "DOUBTFUL")) {
                 temp[[i]] <- subset(temp[[i]], status == "DOUBTFUL")
                 warning_i <- paste(warning_i, "Mapped concept is labelled 'DOUBTFUL'!")
                 temp[[i]] <- subset(temp[[i]], temp[[i]]$confidence == max(temp[[i]]$confidence))
                 if (nrow(temp[[i]]) > 1) {
                     temp[[i]] <- temp[[i]][1, ]
                     warning_i <- paste(warning_i, "Selected first of multiple equally ranked concepts!")
                 }
             }
             rankorder <- c("kingdom", "phylum", "class", "order", "family", "genus", 
                 "species", "subspecies")
             if (match(temp[[i]]$rank, rankorder) > 7 & !subspecies) {
                 if (length(strsplit(as.character(temp[[i]]$canonicalname), " ")[[1]]) > 
                     2) {
                     temp[i] <- taxize::get_gbifid_(paste(strsplit(names(temp[i]), " ")[[1]][1:2], 
                       collapse = " "), messages = verbose)
                     temp[[i]] <- subset(temp[[i]], temp[[i]]$confidence == max(temp[[i]]$confidence))
                     warning_i <- paste(warning_i, "Subspecies has been remapped to species concept!", 
                       sep = " ")
                 }
                 else {
                     temp[[i]] <- data.frame(scientificName = x[i], matchtype = "NONE", 
                       rank = "subspecies")
                     warning_i <- paste(warning_i, "No mapping of subspecies name to species was possible!", 
                       sep = " ")
                 }
             }
             if (temp[[i]]$matchtype == "HIGHERRANK") {
                 if (higherrank) {
                     temp[[i]] <- subset(temp[[i]], temp[[i]]$confidence == max(temp[[i]]$confidence))
                     warning_i <- paste(warning_i, "No matching species concept! Entry has been mapped to higher taxonomic level.")
                 }
                 else {
                     temp[[i]] <- data.frame(scientificName = x[i], matchtype = "NONE", 
                       rank = "highertaxon")
                     warning_i <- paste("No matching species concept!", warning_i)
                 }
             }
             if (temp[[i]]$matchtype != "NONE") {
                 temp[[i]] <- data.frame(scientificName = x[i], synonym = synonym_i, scientificNameStd = temp[[i]]$canonicalname, 
                     author = sub(paste0(temp[[i]]$canonicalname, " "), "", temp[[i]]$scientificname), 
                     taxonRank = temp[[i]]$rank, confidence = temp[[i]]$confidence, kingdom = if (is.null(temp[[i]]$kingdom)) 
                       NA
                     else temp[[i]]$kingdom, phylum = if (is.null(temp[[i]]$phylum)) 
                       NA
                     else temp[[i]]$phylum, class = if (is.null(temp[[i]]$class)) 
                       NA
                     else temp[[i]]$class, order = if (is.null(temp[[i]]$order)) 
                       NA
                     else temp[[i]]$order, family = if (is.null(temp[[i]]$family)) 
                       NA
                     else temp[[i]]$family, genus = if (is.null(temp[[i]]$genus)) 
                       NA
                     else temp[[i]]$genus, taxonomy = "GBIF Backbone Taxonomy", taxonID = paste0("http://www.gbif.org/species/", 
                       temp[[i]]$usagekey, ""), warnings = NA)
             }
             else {
                 temp[[i]] <- data.frame(scientificName = x[i], warnings = NA)
             }
             temp[[i]]$warnings <- warning_i
             if (verbose & nchar(warning_i) >= 1) 
                 warning(warning_i)
         }
         out <- data.table::rbindlist(temp, fill = TRUE)
         class(out) <- c("data.frame", "taxonomy")
         return(out)
     })(c("Acalypta parvula", "Acanthodelphax denticauda", "Acanthodelphax spinosus", 
     "Aspidapion radiolus", "Atheta fungi", "Gymnetron ictericum", "Trigonocranus emmeae"
     ), subspecies = 1, higherrank = 0, verbose = 0, fuzzy = 1, conf_threshold = 90, resolve_synonyms = 1)
  4: taxize::get_gbifid_(x, messages = verbose)
  5: setNames(lapply(sciname, get_gbifd_help, messages = messages, rows = rows, method = method), 
         sciname)
  6: lapply(sciname, get_gbifd_help, messages = messages, rows = rows, method = method)
  7: FUN(X[[i]], ...)
  8: gbif_name_backbone(sciname)
  9: temp$raise_for_status()
  10: fauxpas::http(self, behavior = "stop")
  11: http.HttpResponse(self, behavior = "stop")
  12: tmp$do(response)
  
  ══ testthat results  ═══════════════════════════════════════════════════════════
  OK: 61 SKIPPED: 1 FAILED: 4
  1. Error: gbif taxonomy reachable (@test.map_gbif_taxonomy.R#11) 
  2. Error: mapping synonyms (@test.map_gbif_taxonomy.R#25) 
  3. Error: not matching (@test.map_gbif_taxonomy.R#53) 
  4. Error: mapping of taxa works (@test.standardize.R#21) 
  
  Error: testthat unit tests failed
  Execution halted