Skip to content

Commit

Permalink
use vcr for test request caching
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Jan 29, 2020
1 parent 268699b commit b3b85f5
Show file tree
Hide file tree
Showing 24 changed files with 67,071 additions and 55 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Description: Retrieve, map and summarize data from the 'VertNet.org'
parameters, including 'taxonomic' names, places, and dates. In addition,
there is an interface for conducting spatially delimited searches, and
another for requesting large 'datasets' via email.
Version: 0.7.4.91
Version: 0.7.5.91
Authors@R: c(
person("Scott", "Chamberlain",
role = c("aut", "cre"),
Expand All @@ -30,7 +30,8 @@ Imports:
maps
Suggests:
testthat,
knitr
knitr,
vcr
RoxygenNote: 7.0.2
X-schema.org-applicationCategory: Data Access
X-schema.org-keywords: species, occurrences, biodiversity, maps, vertnet, mammals, mammalia, specimens
Expand Down
30 changes: 30 additions & 0 deletions tests/fixtures/bigsearch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
http_interactions:
- request:
method: get
uri: http://api.vertnet-portal.appspot.com/api/download?q=%7B%22q%22%3A%22specificepithet%3Aprinceps%20genus%3Aochotona%22%2C%22n%22%3A%22test-bigsearch1%22%2C%22e%22%3A%22stuff%40things.com%22%7D
body:
encoding: ''
string: ''
headers:
User-Agent: libcurl/7.54.0 r-curl/4.3 crul/0.9.0
Accept-Encoding: gzip, deflate
Accept: application/json, text/xml, application/xml, */*
response:
status:
status_code: '200'
message: OK
explanation: Request fulfilled, document follows
headers:
status: HTTP/1.1 200 OK
content-type: text/html; charset=utf-8
cache-control: no-cache
x-cloud-trace-context: 3ea5338098e843d315bc875d83eaca20
date: Wed, 29 Jan 2020 16:43:39 GMT
server: Google Frontend
content-length: '0'
body:
encoding: UTF-8
file: no
string: ''
recorded_at: 2020-01-29 16:43:39 GMT
recorded_with: vcr/0.4.0, webmockr/0.5.0
594 changes: 594 additions & 0 deletions tests/fixtures/searchbyterm.yml

Large diffs are not rendered by default.

10,432 changes: 10,432 additions & 0 deletions tests/fixtures/searchbyterm_multiyear_param.yml

Large diffs are not rendered by default.

9,584 changes: 9,584 additions & 0 deletions tests/fixtures/searchbyterm_state_param.yml

Large diffs are not rendered by default.

612 changes: 612 additions & 0 deletions tests/fixtures/spatialsearch.yml

Large diffs are not rendered by default.

442 changes: 442 additions & 0 deletions tests/fixtures/traitsearch.yml

Large diffs are not rendered by default.

240 changes: 240 additions & 0 deletions tests/fixtures/traitsearch_pagination.yml

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions tests/fixtures/vert_id.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
http_interactions:
- request:
method: get
uri: http://api.vertnet-portal.appspot.com/api/search?q=%7B%22q%22%3A%22iptrecordid%3A%5C%22urn%3Acatalog%3ACM%3AHerps%3A116520%5C%22%22%7D
body:
encoding: ''
string: ''
headers:
User-Agent: libcurl/7.54.0 r-curl/4.3 crul/0.9.0
Accept-Encoding: gzip, deflate
Accept: application/json, text/xml, application/xml, */*
response:
status:
status_code: '200'
message: OK
explanation: Request fulfilled, document follows
headers:
status: HTTP/1.1 200 OK
cache-control: no-cache
content-type: application/json
charset: utf-8
x-cloud-trace-context: a90fdc3654cda9f6c7ad2262da20766b
date: Wed, 29 Jan 2020 16:51:58 GMT
server: Google Frontend
content-length: '4311'
body:
encoding: UTF-8
file: no
string: '{"request_date": "2020-01-29T16:51:58.788949", "response_records":
1, "submitted_query": "iptrecordid:\"urn:catalog:CM:Herps:116520\"", "request_origin":
"45.505106,-122.675026", "limit": 400, "cursor": null, "query_version": "search.py
2016-08-15T16:43+02:00", "recs": [{"haslifestage": "0", "month": "8", "decimallongitude":
"-104.19", "startdayofyear": "216", "networks": "HerpNET,VertNet", "vntype":
"specimen", "title": "CM Herps Collection", "accessrights": "http://vertnet.org/resources/norms.html",
"kingdom": "Animalia", "verbatimcoordinatesystem": "decimal degrees", "dctype":
"PhysicalObject", "iptrecordid": "urn:catalog:CM:Herps:116520", "day": "4",
"occurrenceid": "urn:catalog:CM:Herps:116520", "collectioncode": "Herps",
"georeferenceddate": "2006-11-17", "verbatimeventdate": "1965-08-04", "coordinateuncertaintyinmeters":
"20308", "higherclassification": "Animalia | Chordata | Amphibia | Anura |
BUFONIDAE | BUFO", "pubdate": "2017-09-27", "year": "1965", "wasinvasive":
"0", "specificepithet": "debilis", "basisofrecord": "PreservedSpecimen", "geodeticdatum":
"WGS84", "occurrenceremarks": "TOWSON STATE UNIVERSITY COLLECTION.", "highergeography":
"North America | United States | New Mexico | Eddy | | | |", "continent":
"North America", "email": "[email protected]", "orgcountry": "United
States", "source_url": "http://ipt.vertnet.org:8080/ipt/resource.do?r=cm_herps",
"scientificname": "BUFO DEBILIS", "hashid": "3327", "hassex": "0", "language":
"en", "institutionid": "urn:lsid:biocol.org:col:34702", "country": "United
States", "hastissue": "0", "genus": "Bufo", "georeferenceprotocol": "VertNet
Georeferencing Guidelines", "family": "Bufonidae", "stateprovince": "New Mexico",
"rank": 12, "county": "Eddy", "phylum": "Chordata", "references": "http://portal.vertnet.org/o/cm/herps?id=urn-catalog-cm-herps-116520",
"georeferencedby": "Stephen R. (MSB)", "taxonrank": "species", "hasmedia":
"0", "verbatimlocality": "North America | United States | New Mexico | Eddy
| 10 MI S CARLSBAD, BLACK RIVER VILLAGE ROAD", "countrycode": "US", "institutioncode":
"CM", "orgstateprovince": "Pennsylvania", "occurrencestatus": "present", "hastypestatus":
"0", "preparations": "whole animal in alcohol", "recordedby": "FRANZ, L R",
"isfossil": "0", "license": "https://creativecommons.org/publicdomain/zero/1.0/",
"wascaptive": "0", "georeferenceverificationstatus": "requires verification",
"modified": "2017-08-15", "haslicense": "1", "fieldnumber": "LRF 1512", "eventdate":
"1965-08-04", "individualcount": "1", "bibliographiccitation": "Carnegie Museum
of Natural History. CM Herps Collection. Record ID: urn:catalog:CM:Herps:116520.
Source: http://ipt.vertnet.org:8080/ipt/resource.do?r=cm_herps (source published
on 2017-09-27)", "citation": "Carnegie Museum of Natural History. CM Herps
Collection. Source: http://ipt.vertnet.org:8080/ipt/resource.do?r=cm_herps
(source published on 2017-09-27)", "georeferencesources": "ArcGIS software
with data from New Mexico Resource Geographic Information System Program (http://rgis.unm.edu)
and other inhouse resources (historical maps aiding with name changes)", "lastindexed":
"2017-10-19", "haslength": "0", "catalognumber": "116520", "emlrights": "Carnegie
Museum of Natural History (CM) data records may be used by individual researchers
or research groups, but they may not be repackaged, resold, or redistributed
in any form without the express written consent of a curatorial staff member
of the CM. If any of these records are used in an analysis or report, the
provenance of the original data must be acknowledged and the CM notified.
The CM and its staff are not responsible for damages, injury or loss due to
the use of these data.", "hasmass": "0", "gbifdatasetid": "76dd8f0d-2daa-4a69-9fcd-55e04230334a",
"locality": "10 MI S CARLSBAD, BLACK RIVER VILLAGE ROAD", "orgname": "Carnegie
Museum of Natural History", "keyname": "cm/herps/urn-catalog-cm-herps-116520",
"migrator": "2015-09-05", "recordnumber": "TSU 26", "icode": "CM", "gbifpublisherid":
"c1da06f0-580e-11dc-8a9e-b8a03c50a862", "class": "Amphibia", "decimallatitude":
"32.23", "mappable": "1", "nomenclaturalcode": "ICZN", "contact": "Stephen
Rogers", "order": "Anura", "enddayofyear": "216"}], "matching_records": 1,
"api_version": "api.py 2017-11-24T12:16-03:00"}'
recorded_at: 2020-01-29 16:51:58 GMT
recorded_with: vcr/0.4.0, webmockr/0.5.0
Loading

0 comments on commit b3b85f5

Please sign in to comment.