Skip to content
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
3 changes: 3 additions & 0 deletions .github/workflows/check-standard-real-requests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
branches: main
schedule:
- cron: '23 3 23 * *'
workflow_dispatch:

name: R-CMD-check-real-requests

Expand All @@ -33,6 +34,7 @@ jobs:
EDI_USER: ${{ secrets.EDI_USER }}
EDI_PASS: ${{ secrets.EDI_PASS }}
EDI_API_KEY: ${{ secrets.EDI_API_KEY }}
EDI_TEST_THROTTLE_DELAY: 2
RUN_ALL_TESTS: true
VCR_TURN_OFF: true

Expand Down Expand Up @@ -75,6 +77,7 @@ jobs:
EDI_USER: ${{ secrets.EDI_USER }}
EDI_PASS: ${{ secrets.EDI_PASS }}
EDI_API_KEY: ${{ secrets.EDI_API_KEY }}
EDI_TEST_THROTTLE_DELAY: 2
RUN_ALL_TESTS: true
VCR_TURN_OFF: true

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: development
pull_request:
branches: development
workflow_dispatch:

name: R-CMD-check

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: EDIutils
Title: An API Client for the Environmental Data Initiative Repository
Version: 3.0.0
Version: 3.0.1
Authors@R:
c(person("Colin", "Smith", email = "colin.smith@wisc.edu", role = c("aut", "cre"), comment = "0000-0003-2261-9931"),
person("Corinna", "Gries", role = "ctb", comment = "0000-0002-9091-6543"),
Expand Down
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
EDIutils 3.0.1 (2026-08-18)
===========================

### MINOR IMPROVEMENTS

* Migrated the test suite and VCR cassette fixtures to the PASTA staging environment (`https://pasta-s.lternet.edu`), preventing test pollution on the production repository.
* Enhanced entity and descendant tests to dynamically resolve entity IDs and derived package identifiers at runtime.
* Added configurable request throttling (`EDI_TEST_THROTTLE_DELAY`, default 2s in CI) for live HTTP test requests to prevent HTTP 429 rate limit errors.
* Configured VCR cassette mocks for `read_data_package_archive()`.
* Refactored test-only helper functions into `tests/testthat/helper-test-package.R` to keep package runtime namespace clean and modular.
* Updated GitHub Actions CI workflows with sequential execution (`max-parallel: 1`), request throttling, and `workflow_dispatch` manual triggers.


EDIutils 3.0.0 (2026-07-27)
===========================

Expand Down
5 changes: 3 additions & 2 deletions R/read_data_package_from_doi.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' format "shoulder/pasta/md5"
#' @param ore (logical) Return an OAI-ORE compliant resource map in RDF-XML
#' format
#' @inheritParams read_metadata
#'
#' @return (character or xml_document) A resource map with reference URLs to
#' each of the metadata, data, and quality report resources that comprise the
Expand Down Expand Up @@ -43,8 +44,8 @@
#' #> [7] <rdf:Description rdf:about="http://www.openarchives.org/ore/terms ...
#' #> [8] <rdf:Description rdf:about="http://www.openarchives.org/ore/terms ...
#' }
read_data_package_from_doi <- function(doi, ore = FALSE) {
url <- paste0(base_url("production"), "/package/doi/", doi)
read_data_package_from_doi <- function(doi, ore = FALSE, env = "production") {
url <- paste0(base_url(env), "/package/doi/", doi)
if (ore) {
url <- paste0(url, "?ore")
}
Expand Down
148 changes: 1 addition & 147 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,97 +92,6 @@ base_url_portal <- function(env) {



#' Set environment variables for testing data package evaluation and upload
#'
#' @description Testing data package evaluation and upload requires a web
#' accessible data entity, EML metadata describing the data entity, and an EDI
#' repository user account. Use of this function presupposes the data entity
#' has been stashed
#'
#' @param userId (character) EDI repository userId
#' @param url (character) URL from which the EDI repository can download the
#' test data.txt entity. This URL cannot contain any redirects.
#'
#' @return Environmental variables \code{EDI_USERID = userId} and
#' \code{EDI_TEST_URL = url}
#'
#' @details The results of this function are used to create a test EML file for
#' create, update, and delete tests.
#'
#' @noRd
#'
config_test_eml <- function(userId, url) {
Sys.setenv(EDI_USERID = userId)
Sys.setenv(EDI_TEST_URL = url)
}








#' Create an EML file for testing create, update, delete operations
#'
#' @param path (character) Path to directory in which the test EML will be
#' written to file
#' @param packageId (character) Package identifier, of the form
#' "scope.identifier.revision", for the new EML file
#' @param edi_id (character) The EDI ID of the user creating the test EML.
#' An EDI ID can be obtained from the EDI Identity and Access
#' Manager (\url{https://auth.edirepository.org/auth/ui/signin}).
#'
#' @return (character) Full path to EML file written by this function to
#' \code{path}. Should be \code{tempdir()} if executed in a testthat context.
#'
#' @details Copies "eml.xml" at /inst/extdata, adds the userId, packageId, and
#' URL, then writes to \code{paste0(path, "/", packageId, ".xml)}
#'
#' @noRd
#'
create_test_eml <- function(path, packageId, edi_id) {
# Read EML template
eml <- system.file("extdata", "eml.xml", package = "EDIutils")
eml <- xml2::read_xml(eml)
# Add packageId
xml2::xml_attr(eml, "packageId") <- packageId
# Add principal
principal <- xml2::xml_find_first(eml, ".//principal")
xml2::xml_text(principal) <- edi_id
# Add URL
url <- xml2::xml_find_first(eml, ".//online/url")
xml2::xml_text(url) <- Sys.getenv("EDI_TEST_URL")
# Write file
xml2::write_xml(eml, paste0(path, "/", packageId, ".xml"))
dest <- paste0(path, "/", packageId, ".xml")
return(dest)
}








#' Get the first data package in the staging environment for testing
#'
#' @return (character) Data package ID of the form "scope.identifier.revision".
#'
#' @noRd
#'
get_test_package <- function() {
user_data_packages <- list_user_data_packages("EDI-0c385786add7d657afe19ddf52858a6a7226ba32", env = "staging")
return(user_data_packages[1])
}







#' Parse package ID into scope, identifier, and revision
#'
#' @param package.id (character) Data packageId
Expand Down Expand Up @@ -363,7 +272,7 @@ is_vcr_replaying <- function() {
if (requireNamespace("vcr", quietly = TRUE)) {
cass <- vcr::current_cassette()
if (!is.null(cass)) {
return(cass$record %in% c("none", "once"))
return(cass$replaying())
}
}
return(FALSE)
Expand Down Expand Up @@ -430,61 +339,6 @@ api_delete <- function(url, ...) {



#' Skip tests when logged out
#'
#' @details Facilitates testing of functions requiring authentication
#'
#' @noRd
#'
skip_if_logged_out <- function() {
has_token <- (Sys.getenv("EDI_TOKEN") != "") && (Sys.getenv("EDI_TOKEN") != "foobar")
has_key <- (Sys.getenv("EDI_API_KEY") != "") && (Sys.getenv("EDI_API_KEY") != "foobar")

if (has_key && tolower(Sys.getenv("RUN_ALL_TESTS")) != "true") {
testthat::skip("Skipping computationally heavy authenticated test. Set RUN_ALL_TESTS='true' to run.")
}

if (has_token || has_key) {
return(invisible(TRUE))
}
testthat::skip("Not run when logged out. Login with 'login()'.")
}








#' Skip tests when EML configuration is missing
#'
#' @details Facilitates testing create, update, and delete for a test data
#' package
#'
#' @noRd
#'
skip_if_missing_eml_config <- function() {
has_userid <- Sys.getenv("EDI_USERID") != ""
has_url <- Sys.getenv("EDI_TEST_URL") != ""
if (has_userid & has_url) {
return(invisible(TRUE))
}
msg <- paste0(
"Not run when test EML config is missing. Set config with ",
"'config_test_eml()'."
)
testthat::skip(msg)
}









#' Convert newline separated text to character vector
#'
#' @param txt (character) New line separated character string returned from
Expand Down
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/ropensci/EDIutils",
"issueTracker": "https://github.com/ropensci/EDIutils/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "3.0.0",
"version": "3.0.1",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -174,7 +174,7 @@
},
"SystemRequirements": null
},
"fileSize": "790.455KB",
"fileSize": "837.79KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down
16 changes: 9 additions & 7 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
## Release Summary
This EDIutils release, version 3.0.0, transitions all API wrapper functions to
support mandatory authenticated access using EDI API keys. To minimize the
impact on downstream workflows, authentication requires minimal updates: users
simply need to set their API key as an environment variable or pass it directly
into the login() function.
This is a minor release (v3.0.1) updating test infrastructure and test isolation:
* Migrated test suite and VCR mock fixtures to the PASTA staging environment to
prevent test pollution on the production repository.
* Dynamically resolve test entity and descendant identifiers.
* Added request throttling for live HTTP test requests to prevent HTTP 429 rate
limiting.
* Modularized internal test helper utilities.


## Test environments
* aarch64-apple-darwin20, (local machine), R 4.6.0
* aarch64-apple-darwin20 (R-hub), R Under development (unstable) (2026-06-24 r90190)
* x86_64-w64-mingw32 (R-hub), R Under development (unstable) (2026-07-26 r90304 ucrt)
* x86_64-w64-mingw32 (R-hub), R Under development (unstable) (2026-08-17 r90424 ucrt)
* x86_64-w64-mingw32 (R-hub), R version 4.6.1 (2026-06-24 ucrt)
* x86_64-w64-mingw32 (R-hub), R version 4.5.3 (2026-03-11 ucrt)
* x86_64-pc-linux-gnu Ubuntu (R-hub), R development (unstable) (2026-07-26 r90304)
* x86_64-pc-linux-gnu Ubuntu (R-hub), R Under development (unstable) (2026-08-17 r90423)
* x86_64-pc-linux-gnu Ubuntu (R-hub), R version 4.6.1 RC (2026-06-18 r90185)
* x86_64-pc-linux-gnu Ubuntu (R-hub), R version 4.6.1 (2026-06-24)

Expand Down
5 changes: 4 additions & 1 deletion man/read_data_package_from_doi.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/fixtures/create_data_package_archive.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
http_interactions:
- request:
method: post
uri: https://pasta.lternet.edu/package/archive/eml/knb-lter-sev/31999/1
uri: https://pasta-s.lternet.edu/package/archive/eml/edi/1923/1
body:
encoding: ''
string: ''
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/get_audit_count.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
http_interactions:
- request:
method: get
uri: https://pasta.lternet.edu/audit/count?category=warn&fromTime=2021-12-01&toTime=2021-12-05
uri: https://pasta-s.lternet.edu/audit/count?category=warn&fromTime=2021-12-01&toTime=2021-12-05
body:
encoding: ''
string: ''
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/get_audit_csv_report.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/fixtures/get_audit_report.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions tests/fixtures/get_docid_reads.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
http_interactions:
- request:
method: get
uri: https://pasta.lternet.edu/audit/reads/knb-lter-sgs/817
uri: https://pasta-s.lternet.edu/audit/reads/edi/1923
body:
encoding: ''
string: ''
Expand All @@ -28,7 +28,7 @@ http_interactions:
<?xml version="1.0" encoding="UTF-8"?>
<resourceReads>
<resource>
<resourceId>https://pasta.lternet.edu/package/metadata/eml/knb-lter-sgs/817/17</resourceId>
<resourceId>https://pasta-s.lternet.edu/package/metadata/eml/knb-lter-sgs/817/17</resourceId>
<resourceType>metadata</resourceType>
<scope>knb-lter-sgs</scope>
<identifier>817</identifier>
Expand All @@ -37,7 +37,7 @@ http_interactions:
<nonRobotReads>518</nonRobotReads>
</resource>
<resource>
<resourceId>https://pasta.lternet.edu/package/eml/knb-lter-sgs/817/17</resourceId>
<resourceId>https://pasta-s.lternet.edu/package/eml/knb-lter-sgs/817/17</resourceId>
<resourceType>dataPackage</resourceType>
<scope>knb-lter-sgs</scope>
<identifier>817</identifier>
Expand All @@ -46,7 +46,7 @@ http_interactions:
<nonRobotReads>394</nonRobotReads>
</resource>
<resource>
<resourceId>https://pasta.lternet.edu/package/report/eml/knb-lter-sgs/817/17</resourceId>
<resourceId>https://pasta-s.lternet.edu/package/report/eml/knb-lter-sgs/817/17</resourceId>
<resourceType>report</resourceType>
<scope>knb-lter-sgs</scope>
<identifier>817</identifier>
Expand All @@ -55,7 +55,7 @@ http_interactions:
<nonRobotReads>11</nonRobotReads>
</resource>
<resource>
<resourceId>https://pasta.lternet.edu/package/data/eml/knb-lter-sgs/817/17/7c1ee60c37b60b35f05c94475c070750</resourceId>
<resourceId>https://pasta-s.lternet.edu/package/data/eml/knb-lter-sgs/817/17/7c1ee60c37b60b35f05c94475c070750</resourceId>
<resourceType>data</resourceType>
<scope>knb-lter-sgs</scope>
<identifier>817</identifier>
Expand Down
Loading
Loading