-
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.
- Loading branch information
Showing
2 changed files
with
99 additions
and
16 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,81 @@ | ||
http_interactions: | ||
- request: | ||
method: get | ||
uri: https://ebird.org/ws2.0/product/checklist/view/S117450946 | ||
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-type: application/json;charset=utf-8 | ||
date: Sat, 23 Mar 2024 05:57:03 GMT | ||
expires: '0' | ||
pragma: no-cache | ||
server: Apache | ||
strict-transport-security: max-age=31536000 ; includeSubDomains | ||
vary: Origin,Accept-Encoding,Access-Control-Request-Method,Access-Control-Request-Headers | ||
x-content-type-options: nosniff | ||
x-frame-options: DENY | ||
x-xss-protection: 1; mode=block | ||
content-length: '572' | ||
body: | ||
encoding: '' | ||
file: no | ||
string: '{"projId":"EBIRD","subId":"S117450946","protocolId":"P21","locId":"L2906552","durationHrs":0.05,"allObsReported":true,"comments":"7 | ||
passing cars","creationDt":"2022-08-23 15:18","lastEditedDt":"2022-08-23 15:18","obsDt":"2022-05-30 | ||
06:55","obsTimeValid":true,"checklistId":"CL24321","numObservers":1,"subnational1Code":"US-WA","submissionMethodCode":"EBIRD_upload","userDisplayName":"Dave | ||
Slager","numSpecies":5,"subAux":[{"subId":"S117450946","fieldName":"nocturnal","entryMethodCode":"ebird_nocturnal","auxCode":"0"}],"subAuxAi":[],"obs":[{"speciesCode":"hummin","hideFlags":[],"obsDt":"2022-05-30 | ||
06:55","subnational1Code":"US-WA","howManyAtleast":1,"howManyAtmost":1,"present":false,"subId":"S117450946","projId":"EBIRD","obsId":"OBS1503894279","howManyStr":"1"},{"speciesCode":"eursta","hideFlags":[],"exoticCategory":"N","obsDt":"2022-05-30 | ||
06:55","subnational1Code":"US-WA","howManyAtleast":6,"howManyAtmost":6,"present":false,"subId":"S117450946","projId":"EBIRD","obsId":"OBS1503894277","howManyStr":"6"},{"speciesCode":"amerob","hideFlags":[],"obsDt":"2022-05-30 | ||
06:55","subnational1Code":"US-WA","howManyAtleast":2,"howManyAtmost":2,"present":false,"subId":"S117450946","projId":"EBIRD","obsId":"OBS1503894275","howManyStr":"2"},{"speciesCode":"cedwax","hideFlags":[],"obsDt":"2022-05-30 | ||
06:55","subnational1Code":"US-WA","howManyAtleast":2,"howManyAtmost":2,"present":false,"subId":"S117450946","projId":"EBIRD","obsId":"OBS1503894278","howManyStr":"2"},{"speciesCode":"houspa","hideFlags":[],"exoticCategory":"N","obsDt":"2022-05-30 | ||
06:55","subnational1Code":"US-WA","howManyAtleast":1,"howManyAtmost":1,"comments":"ON","present":false,"subId":"S117450946","projId":"EBIRD","obsId":"OBS1503894274","howManyStr":"1","obsAux":[{"subId":"S117450946","fieldName":"breeding_code","entryMethodCode":"ebird_breeding_code","auxCode":"ON","obsId":"OBS1503894274","speciesCode":"houspa","value":"ON"}]},{"speciesCode":"pswspa1","hideFlags":[],"obsDt":"2022-05-30 | ||
06:55","subnational1Code":"US-WA","howManyAtleast":1,"howManyAtmost":1,"present":false,"subId":"S117450946","projId":"EBIRD","obsId":"OBS1503894276","howManyStr":"1"}]}' | ||
recorded_at: 2024-03-23 06:01:43 GMT | ||
recorded_with: vcr/1.2.2, webmockr/0.9.0 | ||
- request: | ||
method: get | ||
uri: https://ebird.org/ws2.0/product/checklist/view/invalid_id | ||
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-type: application/json | ||
date: Sat, 23 Mar 2024 05:57:04 GMT | ||
expires: '0' | ||
pragma: no-cache | ||
server: Apache | ||
strict-transport-security: max-age=31536000 ; includeSubDomains | ||
vary: Origin,Accept-Encoding,Access-Control-Request-Method,Access-Control-Request-Headers | ||
x-content-type-options: nosniff | ||
x-frame-options: DENY | ||
x-xss-protection: 1; mode=block | ||
content-length: '129' | ||
body: | ||
encoding: '' | ||
file: no | ||
string: '{"errors":[{"status":"400 BAD_REQUEST","code":"Pattern","title":"Field | ||
subId of checklistBySubIdCmd: subId is invalid."}]}' | ||
recorded_at: 2024-03-23 06:01:43 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,25 +1,27 @@ | ||
test_that("ebirdchecklist succeeds reproducibly", { | ||
vcr::use_cassette("ebirdchecklist", { | ||
test_that("ebirdchecklist succeeds reproducibly", { | ||
|
||
expect_no_error(out1 <- ebirdchecklist("S117450946")) | ||
expect_no_error(out1 <- ebirdchecklist("S117450946")) | ||
|
||
# check all list-columns removed during preprocessing | ||
expect_false(any(vapply(out1, is.list, logical(1)))) | ||
# check all list-columns removed during preprocessing | ||
expect_false(any(vapply(out1, is.list, logical(1)))) | ||
|
||
# Works with breeding code | ||
expect_true('ON' %in% out1$auxCode) | ||
# Works with breeding code | ||
expect_true('ON' %in% out1$auxCode) | ||
|
||
expect_is(out1, "data.frame") | ||
expect_true(nrow(out1) == 6) | ||
expect_true(ncol(out1) > 0) | ||
expect_true("checklistId" %in% names(out1)) | ||
expect_equal(out1$checklistId[1], "CL24321") | ||
expect_is(out1, "data.frame") | ||
expect_true(nrow(out1) == 6) | ||
expect_true(ncol(out1) > 0) | ||
expect_true("checklistId" %in% names(out1)) | ||
expect_equal(out1$checklistId[1], "CL24321") | ||
|
||
}) | ||
}) | ||
|
||
test_that("ebirdchecklist errors for bad input", { | ||
test_that("ebirdchecklist errors for bad input", { | ||
|
||
invalid_checklist_id <- "invalid_id" | ||
invalid_checklist_id <- "invalid_id" | ||
|
||
# Expect an error and check if the error message matches the expected pattern | ||
expect_error(ebirdchecklist(invalid_checklist_id), "subId is invalid") | ||
# Expect an error and check if the error message matches the expected pattern | ||
expect_error(ebirdchecklist(invalid_checklist_id), "subId is invalid") | ||
}) | ||
}) |