Tests use vcr to record/replay HTTP responses (~8 sec vs minutes).
devtools::test() # All tests
devtools::test(filter="search-pv") # runs just test-search-pv.R
Delete one or more of the YAML files and re-run the test (requires PATENTSVIEW_API_KEY):
unlink("tests/testthat/_vcr/my-test.yml")
devtools::test()
The vcr package checks for an environmental variable VCR_TURN_OFF. If true it turns off all vcr usage so that all requests are live. It would be a good idea to do this after an API release.
Sys.setenv(VCR_TURN_OFF = "true")
devtools::test()
When running live, test-api-bugs.R hits the API to detect when bugs are fixed. When a test fails, the bug may be fixed - verify and remove the workaround.
unlink("tests/testthat/_vcr/bug*.yml")
devtools::test(filter="api-bugs")
Use vcr::local_cassette() with a unique name for any test that calls the API:
test_that("my feature works", {
vcr::local_cassette("my-feature")
result <- search_pv(...)
expect_equal(...)
})
API keys are automatically filtered from cassettes.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.