From 6f85d3b74a12aeff5e5e30cb1f21c00dd358513b Mon Sep 17 00:00:00 2001 From: John Waller Date: Wed, 24 Apr 2024 15:14:27 +0200 Subject: [PATCH] adding error message about full downloads #720 --- R/download_predicate_dsl.R | 5 ++++- tests/testthat/test-occ_download.R | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/R/download_predicate_dsl.R b/R/download_predicate_dsl.R index 6db4d2af..85d483bb 100644 --- a/R/download_predicate_dsl.R +++ b/R/download_predicate_dsl.R @@ -595,7 +595,10 @@ sub_str <- function(str, max = 100) { } parse_predicates <- function(user, email, type, format, ...) { tmp <- list(...) - clzzs <- vapply(tmp, + if(length(tmp) == 0) { + stop("You are requesting a full download. Please use a predicate to filter the data. For example, pred_default().") + } +clzzs <- vapply(tmp, function(z) inherits(z, c("verbatim_extensions","occ_predicate", "occ_predicate_list")), logical(1) ) diff --git a/tests/testthat/test-occ_download.R b/tests/testthat/test-occ_download.R index 7adb0118..578970c2 100644 --- a/tests/testthat/test-occ_download.R +++ b/tests/testthat/test-occ_download.R @@ -219,6 +219,9 @@ test_that("occ_download: real requests work", { "http://rs.gbif.org/terms/1.0/DNADerivedData") expect_equal(length(occ_download_meta(v)$request$verbatimExtensions),2) + # check that full downloads fail well + expect_error(occ_download(), "You are requesting a full download. Please use a predicate to filter the data. For example, pred_default().") + })