-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from ropensci/vcr_ebirdhotspot
vcr tests for ebirdhotspot
- Loading branch information
Showing
2 changed files
with
90 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
http_interactions: | ||
- request: | ||
method: get | ||
uri: https://ebird.org/ws2.0/data/obs/hotspot/recent?fmt=json&maxResults=3&r=L99381&includeProvisional=true | ||
body: | ||
encoding: '' | ||
string: '' | ||
headers: | ||
Accept: application/json, text/xml, application/xml, */* | ||
X-eBirdApiToken: <<<redacted>>> | ||
response: | ||
status: | ||
status_code: 200 | ||
category: Success | ||
reason: OK | ||
message: 'Success: (200) OK' | ||
headers: | ||
cache-control: no-cache, no-store, max-age=0, must-revalidate | ||
content-encoding: gzip | ||
content-length: '299' | ||
content-type: application/json;charset=utf-8 | ||
date: Wed, 06 Mar 2024 06:30:44 GMT | ||
expires: '0' | ||
pragma: no-cache | ||
server: Apache | ||
strict-transport-security: max-age=31536000 ; includeSubDomains | ||
vary: | ||
- Accept-Encoding | ||
- Accept-Encoding,Origin,Access-Control-Request-Method,Access-Control-Request-Headers | ||
x-content-type-options: nosniff | ||
x-frame-options: DENY | ||
x-xss-protection: 1; mode=block | ||
body: | ||
encoding: '' | ||
file: no | ||
string: '[{"speciesCode":"cangoo","comName":"Canada Goose","sciName":"Branta | ||
canadensis","locId":"L99381","locName":"Stewart Park","obsDt":"2024-03-05 | ||
16:38","howMany":2,"lat":42.460791,"lng":-76.5068525,"obsValid":true,"obsReviewed":false,"locationPrivate":false,"subId":"S163830741"},{"speciesCode":"mallar3","comName":"Mallard","sciName":"Anas | ||
platyrhynchos","locId":"L99381","locName":"Stewart Park","obsDt":"2024-03-05 | ||
16:38","howMany":2,"lat":42.460791,"lng":-76.5068525,"obsValid":true,"obsReviewed":false,"locationPrivate":false,"subId":"S163830741"},{"speciesCode":"commer","comName":"Common | ||
Merganser","sciName":"Mergus merganser","locId":"L99381","locName":"Stewart | ||
Park","obsDt":"2024-03-05 16:38","howMany":2,"lat":42.460791,"lng":-76.5068525,"obsValid":true,"obsReviewed":false,"locationPrivate":false,"subId":"S163830741"}]' | ||
recorded_at: 2024-03-06 06:34:11 GMT | ||
recorded_with: vcr/1.2.2, webmockr/0.9.0 | ||
- request: | ||
method: get | ||
uri: https://ebird.org/ws2.0/data/obs/hotspot/recent?fmt=json&back=40&r=L99381 | ||
body: | ||
encoding: '' | ||
string: '' | ||
headers: | ||
Accept: application/json, text/xml, application/xml, */* | ||
X-eBirdApiToken: <<<redacted>>> | ||
response: | ||
status: | ||
status_code: 400 | ||
category: Client error | ||
reason: Bad Request | ||
message: 'Client error: (400) Bad Request' | ||
headers: | ||
cache-control: no-cache, no-store, max-age=0, must-revalidate | ||
content-encoding: gzip | ||
content-length: '146' | ||
content-type: application/json | ||
date: Wed, 06 Mar 2024 06:30:45 GMT | ||
expires: '0' | ||
pragma: no-cache | ||
server: Apache | ||
strict-transport-security: max-age=31536000 ; includeSubDomains | ||
vary: | ||
- Accept-Encoding | ||
- Accept-Encoding,Origin,Access-Control-Request-Method,Access-Control-Request-Headers | ||
x-content-type-options: nosniff | ||
x-frame-options: DENY | ||
x-xss-protection: 1; mode=block | ||
body: | ||
encoding: '' | ||
file: no | ||
string: '{"errors":[{"status":"400 BAD_REQUEST","code":"error.data.too_many_back","title":"Field | ||
back of rawDataCmd: The maximum number of days back is 30"}]}' | ||
recorded_at: 2024-03-06 06:34:11 GMT | ||
recorded_with: vcr/1.2.2, webmockr/0.9.0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
context("ebirdhotspot") | ||
vcr::use_cassette("ebirdhotspot", { | ||
test_that("ebirdhotspot works correctly", { | ||
|
||
test_that("ebirdhotspot works correctly", { | ||
skip_on_cran() | ||
skip_on_ci() | ||
|
||
expect_warning(out <- ebirdhotspot('L99381', max = 10, provisional = TRUE)) | ||
expect_is(out, "data.frame") | ||
expect_is(out$comName, "character") | ||
expect_warning(ebirdhotspot('L99381')) | ||
|
||
expect_warning(expect_error(ebirdhotspot(locID = 'L99381', back = 40))) | ||
expect_warning(out <- ebirdhotspot('L99381', max = 3, provisional = TRUE)) | ||
expect_is(out, "data.frame") | ||
expect_is(out$comName, "character") | ||
expect_warning(expect_error(ebirdhotspot(locID = letters))) | ||
expect_warning(expect_error(ebirdhotspot(locID = 'L99381', back = 40))) | ||
}) | ||
}) |