Skip to content

Commit

Permalink
Merge pull request #55 from allenbaron/fix_ftxt
Browse files Browse the repository at this point in the history
Update empc_ftxt() to indicate 1 input limit
  • Loading branch information
njahn82 committed Nov 20, 2023
2 parents b3d4794 + 99fb4ba commit 86ccdfc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions R/epmc_ftxt.r
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_epmc_ftxt.r
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ 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")

# fails correctly
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'"
)
})

0 comments on commit 86ccdfc

Please sign in to comment.