Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for readr 2.0.0 #37

Merged
merged 1 commit into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions R/rglobi.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ has_neo4j_api <- function() {
# @param url points to csv resource
read_csv_online <- function(url, ...) {
if (has_api()) {
as.data.frame(suppressMessages(readr::read_csv(url)))
} else {
stop(paste("GloBI data services are not available at [", globi_api_url, "]. Are you connected to the internet?", sep = ""))
res <- suppressWarnings(suppressMessages(as.data.frame(readr::read_csv(url))))

# Drop rows with all NAs
res <- res[rowSums(is.na(res)) != ncol(res), ]

return(res)
}

stop(paste("GloBI data services are not available at [", globi_api_url, "]. Are you connected to the internet?", sep = ""))
}

#' Get Species Interaction from GloBI
Expand Down
7 changes: 6 additions & 1 deletion tests/testthat/util.R → tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ read_csv_caching = function(url, ...) {
}

read_csv_offline = function(url, ...) {
readr::read_csv(cached_filename(url))
res <- suppressWarnings(suppressMessages(as.data.frame(readr::read_csv(cached_filename(url), progress = FALSE))))

# Drop rows with all NAs
res <- res[rowSums(is.na(res)) != ncol(res), ]

res
}
2 changes: 0 additions & 2 deletions tests/testthat/test-globi.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
context("rglobi")

source('util.R')

test_that("default prey", {
predatorPrey <- get_prey_of(taxon = "Homo sapiens", read_csv = read_csv_offline)
expect_true(length(predatorPrey) > 0)
Expand Down