From e524968569f47a22fce2d27487932bc90618fa2b Mon Sep 17 00:00:00 2001 From: Jeanette Clark Date: Fri, 6 Sep 2024 17:25:42 +0000 Subject: [PATCH] skip scopus and springer tests if no key is set --- tests/testthat/test-scopus.R | 32 ++++++++++++++++++++------------ tests/testthat/test-springer.R | 7 +++++++ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/tests/testthat/test-scopus.R b/tests/testthat/test-scopus.R index 6889b62..385d562 100644 --- a/tests/testthat/test-scopus.R +++ b/tests/testthat/test-scopus.R @@ -1,14 +1,22 @@ test_that("scopus finds single known doi", { - skip_on_cran() - - # Pull single test doi citation from test-citations.csv - test_cit <- get_test_doi("scopus") - - # Search for single test doi using citation_search_springer() function - scopus_res <- - citation_test_doi("scopus") # Need to key API keys in order for this to work - - if (!is.null(scopus_res)) { - expect_true(test_cit$pub_id %in% scopus_res$article_id) - } + skip_on_cran() + + key <- scythe_get_key("scopus") + + if (is.na(key)){ + skip() + message("No Scopus key set. Skipping.") + } + + + # Pull single test doi citation from test-citations.csv + test_cit <- get_test_doi("scopus") + + # Search for single test doi using citation_search_springer() function + scopus_res <- + citation_test_doi("scopus") # Need to key API keys in order for this to work + + if (!is.null(scopus_res)) { + expect_true(test_cit$pub_id %in% scopus_res$article_id) + } }) diff --git a/tests/testthat/test-springer.R b/tests/testthat/test-springer.R index 8d0655f..67fcab7 100644 --- a/tests/testthat/test-springer.R +++ b/tests/testthat/test-springer.R @@ -1,6 +1,13 @@ test_that("springer finds single known doi", { skip_on_cran() + key <- scythe_get_key("springer") + + if (is.na(key)){ + skip() + message("No Springer key set. Skipping.") + } + # Pull single test doi citation from test-citations.csv test_cit <- get_test_doi("springer")