Skip to content

NRP-83 Using http to mock some API respones, however, some tests need…#63

Merged
sedv8808 merged 3 commits into
devfrom
tests/fixing_speed
Jul 24, 2026
Merged

NRP-83 Using http to mock some API respones, however, some tests need…#63
sedv8808 merged 3 commits into
devfrom
tests/fixing_speed

Conversation

@sedv8808

Copy link
Copy Markdown
Collaborator

This pull request updates the neotoma2 package to version 1.1.0, adds a new author, expands suggested testing and plotting packages, and introduces several new API response fixtures for offline testing. It also configures .Rbuildignore to exclude these large test fixtures from CRAN builds, keeping the package size manageable.

Package metadata and authorship:

  • Bumps the package version to 1.1.0 in DESCRIPTION.
  • Adds Nick Hoffman as an author with ORCID and email in DESCRIPTION.

Testing and development dependencies:

  • Expands the Suggests field in DESCRIPTION to include Bchron, covr, ggplot2, and httptest for enhanced testing and plotting capabilities.

Test fixtures and build configuration:

  • Adds multiple new API response fixtures under tests/testthat/fixtures/api.neotomadb.org/ for offline testing, covering various dataset endpoints. (tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/1001,2001,15,24.jsonR1-R178, tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/24,100,101.jsonR1-R129, [1] [2] tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/1,2,3,4,5,6,7,7857,8,7858,10469,9,7859,10-c34357.jsonR1-R7)
  • Updates .Rbuildignore to exclude the recorded httptest API response fixtures from CRAN builds, with explanatory comments. [1] [2]… to make sure to touch API. If those tests are too large, using skip_ci as when they are run in gh actions, the test overload is too much.

… to make sure to touch API. If those tests are too large, using skip_ci as when they are run in gh actions, the test overload is too much.
Copilot AI review requested due to automatic review settings July 23, 2026 21:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the neotoma2 package metadata (version/authors/deps) and reworks parts of the test suite to support offline API testing by replaying recorded httptest fixtures, while keeping heavier integration tests live-only (skipped on CI).

Changes:

  • Bump package version to 1.1.0, add a new author, and expand Suggests (including httptest).
  • Wrap many API-touching tests with httptest::with_mock_api() and bound some calls to smaller, fixture-friendly IDs; skip heavy network tests on CI.
  • Add recorded API response fixtures under tests/testthat/fixtures/api.neotomadb.org/ and exclude them from CRAN builds via .Rbuildignore.

Reviewed changes

Copilot reviewed 55 out of 65 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
DESCRIPTION Version bump, author addition, and updated Suggests list (incl. httptest).
.Rbuildignore Exclude recorded httptest fixtures from CRAN tarballs.
tests/testthat/setup.R Configure httptest mock path for fixture replay.
tests/testthat/test_toWide.R Run toWide() tests against mocked API responses.
tests/testthat/test_taxa.R Skip large live API test on CI.
tests/testthat/test_summary.R Bound site IDs and run summary tests under mocked API.
tests/testthat/test_sites.R Run site-retrieval tests under mocked API.
tests/testthat/test_samples.R Mock only small downloads; skip large live tests on CI.
tests/testthat/test_parse_site.R Update parser tests to read JSON fixtures from fixtures/.
tests/testthat/test_length.R Run length/structure tests under mocked API.
tests/testthat/test_group_data.R Update group-response tests to read from fixtures/.
tests/testthat/test_getids.R Run getids() tests under mocked API.
tests/testthat/test_filter.R Restore/organize filter tests; split mocked vs live integration tests.
tests/testthat/test_doi.R Run DOI tests under mocked API.
tests/testthat/test_datasets.R Bound site IDs and run dataset tests under mocked API.
tests/testthat/test_coordinates.R Run coordinates tests under mocked API.
tests/testthat/test_collunits.R Bound site IDs and run collunits tests under mocked API.
tests/testthat/test_clean.R Run object-cleaning test under mocked API fixtures.
tests/testthat/test_cite_data.R Run citation tests under mocked API.
tests/testthat/test_chronologies.R Run chronologies tests under mocked API.
tests/testthat/test_chroncontrols.R Run chroncontrols tests under mocked API.
tests/testthat/test_c.R Run concatenation tests under mocked API.
tests/testthat/test_add_chronology.R Skip heavy live chronology test on CI.
tests/testthat/fixtures/data_sites24.json Hand-made parser fixture (sites endpoint shape).
tests/testthat/fixtures/data_datasets24.json Hand-made parser fixture (datasets endpoint shape).
tests/testthat/fixtures/data_downloads24_dup.json Hand-made parser fixture (downloads endpoint shape, duplication case).
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites/5.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites/24.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites/1001.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites/101,102.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites/24,100.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites/24,1001,2001.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites/1001,2001,15,24.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites/13949,11904,13319,728,13248,2625,2806,13280,519,11745,273,13956,11880,13321,9801,13698,11816,13909,13921.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites-01cad7.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites-6700b2.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites-8d5f39.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/sites-989a41.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/downloads-82c7ed.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/downloads-711600.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/7870.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/24,7870-c34357.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/24,7870-5b7af1.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/24,100.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/24,100,101.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/24-c34357.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/24-5b7af1.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/100-c34357.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/100-5b7af1.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/101-c34357.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/101-5b7af1.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/1001,2001,15,24.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/1,2,3,4,5,6,7,7857,8,7858,10469,9,7859,10-c34357.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets/1,2,3,4,5,6,7,7857,8,7858,10469,9,7859,10-5b7af1.json Recorded API response fixture.
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets-bb3b70-POST.json Recorded API response fixture (POST).
tests/testthat/fixtures/api.neotomadb.org/v2.0/data/datasets-a35fb3.json Recorded API response fixture.
Comments suppressed due to low confidence (1)

DESCRIPTION:41

  • Imports: has trailing whitespace after the field name (Imports: ). Remove the trailing space to keep DESCRIPTION formatting clean and stable.
Imports: 

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/testthat/setup.R
Comment on lines +1 to 8
library(httptest)
# Recorded API responses (and the hand-made parser fixtures) live under
# tests/testthat/fixtures/. Pointing httptest's mock path there keeps every
# `with_mock_api()` recording and replay in one folder instead of scattering a
# `api.neotomadb.org/` tree at the testthat root.
httptest::.mockPaths(testthat::test_path("fixtures"))

# Shared test fixtures, sourced once by testthat before any test file runs.
Comment thread DESCRIPTION
RoxygenNote: 7.3.3
Suggests:
testthat,
Suggests:
Comment on lines 1 to 4
library("testthat")
library("neotoma2")
library("httptest")

Comment on lines 1 to 4
library("testthat")
library("neotoma2")
library("httptest")

@@ -1,8 +1,10 @@
library("testthat")
library("neotoma2")
library("httptest")
@@ -1,8 +1,10 @@
library("testthat")
library("neotoma2")
library("httptest")
Comment thread tests/testthat/test_c.R
@@ -1,7 +1,9 @@
library("testthat")
library("neotoma2")
library("httptest")
Comment thread tests/testthat/test_doi.R
@@ -1,7 +1,9 @@
library("testthat")
library("neotoma2")
library("httptest")
@@ -1,8 +1,10 @@
library("testthat")
library("neotoma2")
library("httptest")
library("testthat")
library("neotoma2")
library("dplyr")
library("httptest")
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@sedv8808
sedv8808 merged commit 493cba7 into dev Jul 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants