Skip to content

Commit

Permalink
Add sleep to each try_again for Pubmed/entrez tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mathew W. McLean <[email protected]>
  • Loading branch information
mwmclean committed Oct 8, 2024
1 parent 45842ed commit 7328319
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions R/ReadPubMed.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ GetPubMedByID <- function(id, db = "pubmed", ...){
## temp <- postForm(base.url, .params = parms)
## tdoc <- xmlParse(temp)
temp <- POST(base.url, query = parms)
stop_for_status(temp)
tdoc <- read_xml(temp)

## Note: directly using xpathApply on tdoc won't work if some results are
Expand Down
7 changes: 3 additions & 4 deletions tests/testthat/test-pubmed.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,17 @@ test_that("LookupPubMedID successfully retrieves and add ID's'", {

test_that("GetPubMedByID reading of years/months (#52)", {
skip_if_offline("eutils.ncbi.nlm.nih.gov")
Sys.sleep(2)
try_again(3, bib <- GetPubMedByID("23891459"))
try_again(3, {Sys.sleep(2); bib <- GetPubMedByID("23891459")})
expect_equal(bib$year, "2013")
expect_equal(bib$month, "07")
})

test_that("GetPubMedByID: Multiple books parsed correctly #86",
{
skip_if_offline("eutils.ncbi.nlm.nih.gov")
Sys.sleep(2)

ids <- c("33780208", "33764725")
names(ids) <- c("geary2021variation", "brennan2021potential")
try_again(5, bib <- GetPubMedByID(ids))
try_again(3, {Sys.sleep(2); bib <- GetPubMedByID(ids)})
expect_equal(unlist(bib$eprint), ids)
})

0 comments on commit 7328319

Please sign in to comment.