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

add ebv_i_check_url function, dontest ebv_download function #41

Merged
merged 1 commit into from
Jul 10, 2024
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
5 changes: 3 additions & 2 deletions R/ebv_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
#' @export
#'
#' @examples
#' #get all available datasets
#' datasets <- ebv_download()
#'
#' \donttest{
#' #' #get all available datasets
#' datasets <- ebv_download()
#'
#' ebv_download(id = datasets$id[1], outputdir =
#' tempdir(), overwrite=TRUE,
#' verbose=FALSE)
Expand Down
13 changes: 13 additions & 0 deletions R/ebv_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -892,3 +892,16 @@
data_level_clean <- enc2utf8(unlist(data_level))
return(data_level_clean)
}

#' Checks if a url is invalid/not reachable
#'
#' @param url String with the url. must start with http(s)://
#'
#' @return Returns TRUE if the url is invalid, else returns FALSE
#' @noRd
ebv_i_check_url <- function(url){
con <- url(url)
check <- suppressWarnings(try(open.connection(con,open="rt",timeout=t),silent=T)[1])

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=53,[commas_linter] Commas should always have a space after.

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=63,[commas_linter] Commas should always have a space after.

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=74,[commas_linter] Commas should always have a space after.

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=82,[T_and_F_symbol_linter] Use TRUE instead of the symbol T.

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=53,[commas_linter] Commas should always have a space after.

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=63,[commas_linter] Commas should always have a space after.

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=74,[commas_linter] Commas should always have a space after.

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=82,[T_and_F_symbol_linter] Use TRUE instead of the symbol T.

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=53,[commas_linter] Commas should always have a space after.

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=63,[commas_linter] Commas should always have a space after.

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=74,[commas_linter] Commas should always have a space after.

Check warning on line 904 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=904,col=82,[T_and_F_symbol_linter] Use TRUE instead of the symbol T.
suppressWarnings(try(close.connection(con),silent=T))

Check warning on line 905 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=905,col=46,[commas_linter] Commas should always have a space after.

Check warning on line 905 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=905,col=54,[T_and_F_symbol_linter] Use TRUE instead of the symbol T.

Check warning on line 905 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=905,col=46,[commas_linter] Commas should always have a space after.

Check warning on line 905 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=905,col=54,[T_and_F_symbol_linter] Use TRUE instead of the symbol T.

Check warning on line 905 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=905,col=46,[commas_linter] Commas should always have a space after.

Check warning on line 905 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=905,col=54,[T_and_F_symbol_linter] Use TRUE instead of the symbol T.
ifelse(is.null(check),FALSE,TRUE)

Check warning on line 906 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=906,col=25,[commas_linter] Commas should always have a space after.

Check warning on line 906 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=906,col=31,[commas_linter] Commas should always have a space after.

Check warning on line 906 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=906,col=25,[commas_linter] Commas should always have a space after.

Check warning on line 906 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=906,col=31,[commas_linter] Commas should always have a space after.

Check warning on line 906 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=906,col=25,[commas_linter] Commas should always have a space after.

Check warning on line 906 in R/ebv_utils.R

View workflow job for this annotation

GitHub Actions / R

file=R/ebv_utils.R,line=906,col=31,[commas_linter] Commas should always have a space after.
}
11 changes: 2 additions & 9 deletions tests/testthat/test-download.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# basic tests for ebv_download ----
#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')
#check url
portal_down <- ebv_i_check_url('https://portal.geobon.org/api/v1/datasets')

if(portal_down){
#expect an error
Expand Down
Loading