@@ -6,7 +6,7 @@ A short checklist for submitting pull requests:
662 . If you have added any new features (new functions, new options, etc.), add a
77 brief description to ` NEWS.md ` to the next listed version number. Also ensure
88 that new functions or datasets are listed in the reference in ` _pkgdown.yml `
9- so they appear in a good place in the documentation website .
9+ so they appear in a good place in the function reference page .
10103 . If you changed any documentation, rebuild the documentation with
1111 ` devtools::document() ` and then ` pkgdown::build_site() ` . (This can be slow,
1212 because our vignettes take a long time to build.)
@@ -25,6 +25,17 @@ when you open a pull request, as part of running `R CMD check`. Failed tests and
2525check errors will both result in the build failing and errors being visible in
2626the pull request.
2727
28+ ### Testing API access
29+
30+ Unit tests should * not* require Internet access. This poses a problem for
31+ testing of functions like ` covidcast_signal() ` . In testing, it is also helpful
32+ to be able to test different custom responses from the API server.
33+
34+ The [ httptest package] ( https://enpiar.com/r/httptest/index.html ) solves these
35+ problems by hooking in to the ` httr ` package and replacing API requests with the
36+ contents of specially named files. See ` tests/testthat/test-covidcast.R ` for
37+ details and examples.
38+
2839### Testing plots
2940
3041We test our plots and maps with the [ vdiffr] ( https://github.com/r-lib/vdiffr )
@@ -78,3 +89,22 @@ After changing a vignette or documentation, you'll need to rebuild the
7889documentation. Use ` devtools::document() ` to do this. Then
7990` pkgdown::build_site(".") ` (from within the package directory) will rebuild the
8091HTML documentation site.
92+
93+ ### Vignettes
94+
95+ Our vignettes can take quite a while to render; much of this time is spent in
96+ downloading data from the COVIDcast API. This can make the package inconvenient
97+ to install, take up time on our CI servers, and may cause issues when we
98+ eventually submit to CRAN.
99+
100+ We hence use [ httptest's vignette
101+ features] ( https://enpiar.com/r/httptest/articles/vignettes.html ) to record API
102+ requests and serve them from static JSON files in the repository, instead of
103+ actual API queries. This cuts the time dramatically. See the httptest
104+ documentation for more details on how this works, and ensure that any new
105+ vignettes use this feature.
106+
107+ To re-download all data for the vignettes, simply delete the corresponding
108+ folder in ` vignettes/ ` and re-build the vignette. For example, delete
109+ ` vignettes/plotting-signals/ ` and then rebuild ` plotting-signals.Rmd ` to have
110+ httptest re-download and save the data.
0 commit comments