-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fix: check if portal website is online
- Loading branch information
1 parent
9634a0f
commit e81af6f
Showing
3 changed files
with
38 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
# basic tests for ebv_download ---- | ||
test_that("test ebv_download ID=numeric", { | ||
dir <- tempdir() | ||
data <- ebv_download(27, dir, verbose = FALSE) | ||
expect_true(basename(data) %in% list.files(dir)) | ||
}) | ||
#check URL | ||
invalid_url <- function(url_in,t=2){ | ||
con <- url(url_in) | ||
check <- suppressWarnings(try(open.connection(con,open="rt",timeout=t),silent=T)[1]) | ||
suppressWarnings(try(close.connection(con),silent=T)) | ||
ifelse(is.null(check),FALSE,TRUE) | ||
} | ||
|
||
portal_down <- invalid_url('https://portal.geobon.org/api/v1/datasets') | ||
|
||
if(portal_down){ | ||
#expect an error | ||
expect_error(ebv_download(27, dir, verbose = FALSE)) | ||
}else{ | ||
#run 'normal' tests | ||
test_that("test ebv_download ID=numeric", { | ||
dir <- tempdir() | ||
data <- ebv_download(27, dir, verbose = FALSE) | ||
expect_true(basename(data) %in% list.files(dir)) | ||
}) | ||
|
||
test_that("test ebv_download ID=doi", { | ||
dir <- tempdir() | ||
data <- ebv_download('10.25829/f2rdp4', dir, verbose = FALSE) | ||
expect_true(basename(data) %in% list.files(dir)) | ||
}) | ||
|
||
test_that("test ebv_download ID=title", { | ||
dir <- tempdir() | ||
data <- ebv_download('Local bird diversity (cSAR/BES-SIM)', dir, verbose = FALSE) | ||
expect_true(basename(data) %in% list.files(dir)) | ||
}) | ||
} | ||
|
||
test_that("test ebv_download ID=doi", { | ||
dir <- tempdir() | ||
data <- ebv_download('10.25829/f2rdp4', dir, verbose = FALSE) | ||
expect_true(basename(data) %in% list.files(dir)) | ||
}) | ||
|
||
test_that("test ebv_download ID=title", { | ||
dir <- tempdir() | ||
data <- ebv_download('Local bird diversity (cSAR/BES-SIM)', dir, verbose = FALSE) | ||
expect_true(basename(data) %in% list.files(dir)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters