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

Update empc_ftxt() to indicate 1 input limit #55

Merged
merged 2 commits into from
Nov 20, 2023
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
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'"
)
})