NRP-83 Using http to mock some API respones, however, some tests need…#63
Merged
Conversation
… 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.
There was a problem hiding this comment.
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 expandSuggests(includinghttptest). - 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 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. |
| 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") | |||
| @@ -1,7 +1,9 @@ | |||
| library("testthat") | |||
| library("neotoma2") | |||
| library("httptest") | |||
| @@ -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") |
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 ☂️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request updates the
neotoma2package 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.Rbuildignoreto exclude these large test fixtures from CRAN builds, keeping the package size manageable.Package metadata and authorship:
1.1.0inDESCRIPTION.DESCRIPTION.Testing and development dependencies:
Suggestsfield inDESCRIPTIONto includeBchron,covr,ggplot2, andhttptestfor enhanced testing and plotting capabilities.Test fixtures and build configuration:
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).Rbuildignoreto exclude the recordedhttptestAPI 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.