From 2652c6dc6686c62c14ed45eb27398faf54b48b40 Mon Sep 17 00:00:00 2001 From: "J. Allen Baron" Date: Fri, 17 Nov 2023 12:31:33 -0500 Subject: [PATCH 1/2] Update empc_ftxt() to indicate 1 input limit --- R/epmc_ftxt.r | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/epmc_ftxt.r b/R/epmc_ftxt.r index 87b8299..e8838d2 100644 --- a/R/epmc_ftxt.r +++ b/R/epmc_ftxt.r @@ -1,6 +1,6 @@ -#' Fetch Europe PMC full texts +#' Fetch Europe PMC full text #' -#' This function loads full texts into R. Full texts are in XML format and are +#' This function loads one full text into R. Full text is in XML format and is #' only provided for the Open Access subset of Europe PMC. #' #' @param ext_id character, PMCID. @@ -15,8 +15,8 @@ #' epmc_ftxt("PMC3639880") #' } epmc_ftxt <- function(ext_id = NULL) { - if (!grepl("^PMC", ext_id)) - stop("Please provide a PMCID, i.e. ids starting with 'PMC'") + if (!grepl("^PMC", ext_id) || length(ext_id) != 1) + stop("Please provide one PMCID, i.e. id starting with 'PMC'") # call api req <- httr::RETRY("GET", From 99fb4ba91b56dec134e4cd2118708fade57efe9f Mon Sep 17 00:00:00 2001 From: "J. Allen Baron" Date: Fri, 17 Nov 2023 14:04:17 -0500 Subject: [PATCH 2/2] Modify error text in epmc_ftxt() test --- tests/testthat/test_epmc_ftxt.r | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test_epmc_ftxt.r b/tests/testthat/test_epmc_ftxt.r index de75551..ae3053b 100644 --- a/tests/testthat/test_epmc_ftxt.r +++ b/tests/testthat/test_epmc_ftxt.r @@ -5,7 +5,7 @@ test_that("epmc_ftxt returns", { a <- epmc_ftxt("PMC3257301") b <- epmc_ftxt("PMC3639880") - #correct class metadata + # correct class metadata expect_is(a, "xml_document") expect_is(b, "xml_document") @@ -13,6 +13,6 @@ test_that("epmc_ftxt returns", { expect_error(epmc_ftxt("2PMC3448176")) expect_error(epmc_ftxt("PMC3476")) expect_error(epmc_ftxt("3476"), - "Please provide a PMCID, i.e. ids starting with 'PMC'" - ) + "Please provide one PMCID, i.e. id starting with 'PMC'" + ) })