Skip to content

Commit 0399e26

Browse files
authored
Merge pull request #53 from iDigBio/update-docs
Resume testing on MacOS and specify HTTP/2
2 parents 62db0d5 + f723390 commit 0399e26

26 files changed

+366
-80
lines changed

.Rbuildignore

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
^docs$
66
^pkgdown$
77
^\.github$
8+
^doc$
9+
^Meta$

.github/workflows/R-Git-Check.yml

+21-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
fail-fast: false
2727
matrix:
2828
config:
29+
- {os: macos-latest, r: 'release'}
2930
- {os: windows-latest, r: 'release'}
3031
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
3132
- {os: ubuntu-latest, r: 'release'}
@@ -35,6 +36,12 @@ jobs:
3536
R_KEEP_PKG_SOURCE: yes
3637

3738
steps:
39+
- name: Install specific version of curl (macOS)
40+
if: runner.os == 'macOS'
41+
run: |
42+
brew reinstall curl # Adjust version as needed
43+
brew link --force curl
44+
3845
- uses: actions/checkout@v4
3946

4047
- uses: r-lib/actions/setup-pandoc@v2
@@ -44,11 +51,24 @@ jobs:
4451
r-version: ${{ matrix.config.r }}
4552
http-user-agent: ${{ matrix.config.http-user-agent }}
4653
use-public-rspm: true
47-
54+
4855
- uses: r-lib/actions/setup-r-dependencies@v2
4956
with:
5057
extra-packages: any::rcmdcheck
5158
needs: check
59+
cache-version: "no-cache"
60+
61+
# Install remotes package to handle versioned installations
62+
- name: Install remotes package
63+
if: runner.os == 'macOS'
64+
run: |
65+
R -e "install.packages('remotes')"
66+
67+
# Install r-curl 5.2.2 from CRAN Archive using remotes
68+
- name: Install r-curl 5.2.2 from CRAN Archive
69+
if: runner.os == 'macOS'
70+
run: |
71+
R -e "remotes::install_version('curl', '5.2.2')"
5272
5373
- uses: r-lib/actions/check-r-package@v2
5474
with:

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
ridigbio.Rproj
66
.DS_Store
77
inst/doc
8-
docs
8+
docs
9+
/doc/
10+
/Meta/

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: ridigbio
22
Title: Interface to the iDigBio Data API
3-
Version: 0.3.9
4-
Date: 2024-8-19
3+
Version: 0.4.0
4+
Date: 2024-9-3
55
Encoding: UTF-8
66
Authors@R: c(person("Francois", "Michonneau", comment="Original Author", role=c("aut", "cph"),
77

NEWS.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
ridigbio 0.4.0
2+
===========
3+
### Enhancements
4+
* Offline build capability added
5+
16
ridigbio 0.3.9
27
===========
38

R/base.R

+21-9
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,27 @@ idig_parse <- function(req) {
4747
##' @return nothing. Stops if HTTP code is >= 400
4848
##' @author Francois Michonneau
4949
idig_check <- function(req) {
50-
if (req$status_code >= 400) {
51-
msg <- substr(req, 1, 200)
52-
stop("HTTP failure: ", req$status_code, "\n",
53-
"Error message from API server: ", msg,
54-
call. = FALSE
55-
)
56-
}
57-
idig_check_error(req)
50+
tryCatch(
51+
{
52+
if (req$status_code >= 400) {
53+
msg <- substr(req, 1, 200)
54+
stop("HTTP failure: ", req$status_code, "\n",
55+
"Error message from API server: ", msg,
56+
call. = FALSE
57+
)
58+
}
59+
idig_check_error(req)
60+
},
61+
error = function(e) {
62+
warning("Error during API request: ", e$message)
63+
msg <- substr(req, 1, 200)
64+
stop("HTTP failure: ", req$status_code, "\n",
65+
"Error message from API server: ", msg,
66+
call. = FALSE
67+
)
68+
idig_check_error(req)
69+
}
70+
)
5871
}
5972

6073
##' Checks for error messages that can be returned by the API in JSON.
@@ -110,7 +123,6 @@ idig_POST <- function(path, body, ...) {
110123
httr::content_type_json(), ...
111124
)
112125
idig_check(req)
113-
114126
req
115127
}
116128

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ library("ridigbio")
5757
idig_search_records(rq=list(genus="galax"))
5858
idig_search_records(rq=list(family="diapensiaceae"), limit=1000)
5959
```
60-
6160
# Meta
6261

6362
* [Please report any bugs or issues.](https://github.com/iDigBio/ridigbio/issues)

tests/testthat/test-base.R

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ context("test GET")
33

44
test_that("list of all top-level fields returned in JSON", {
55
testthat::skip_on_cran()
6+
testthat::skip_if_offline()
67
getReq <- list(rq = jsonlite::toJSON(list(family = "holothuriidae")))
78
r <- idig_GET("search/records", query = getReq)
89

@@ -16,6 +17,7 @@ context("test POST")
1617

1718
test_that("list of all top-level fields returned in JSON", {
1819
testthat::skip_on_cran()
20+
testthat::skip_if_offline()
1921
fm <- list(rq = list(family = "holothuriidae"))
2022
r <- idig_POST("search/records", body = fm)
2123

@@ -25,6 +27,7 @@ test_that("list of all top-level fields returned in JSON", {
2527

2628
test_that("400 errors print messages", {
2729
testthat::skip_on_cran()
30+
testthat::skip_if_offline()
2831

2932
expect_error(
3033
idig_search_records(rq = list("asdf" = "asdf")),

tests/testthat/test-idig_build_attrib.R

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ context("test idig_build_attrib")
22

33
test_that("attribution dataframe built from results dataframe and item counts match", {
44
testthat::skip_on_cran()
5+
testthat::skip_if_offline()
56

67
testQuery <- idig_search_records(rq = list(family = "holothuriidae"))
78
df <- idig_build_attrib(testQuery)
@@ -11,6 +12,7 @@ test_that("attribution dataframe built from results dataframe and item counts ma
1112

1213
test_that("limited results, attribution counts match limit and result counts", {
1314
testthat::skip_on_cran()
15+
testthat::skip_if_offline()
1416

1517
df <- idig_search_records(rq = list(genus = "acer"), limit = 10)
1618
tt <- idig_build_attrib(df)

tests/testthat/test-idig_count_media.R

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ dqs <- 0
55

66
test_that("all media records is a large number", {
77
testthat::skip_on_cran()
8+
testthat::skip_if_offline()
9+
810
num <- idig_count_media()
911

1012
expect_that(num, is_a("integer"))
@@ -14,6 +16,8 @@ test_that("all media records is a large number", {
1416

1517
test_that("rq searches on the endpoint is a small number", {
1618
testthat::skip_on_cran()
19+
testthat::skip_if_offline()
20+
1721
num <- idig_count_media(rq = list("recordset" = recordset))
1822

1923
expect_that(num, is_a("integer"))
@@ -22,6 +26,8 @@ test_that("rq searches on the endpoint is a small number", {
2226

2327
test_that("mq searches on the endpoint is a small number", {
2428
testthat::skip_on_cran()
29+
testthat::skip_if_offline()
30+
2531
num <- idig_count_media(mq = list("dqs" = dqs))
2632

2733
expect_that(num, is_a("integer"))

tests/testthat/test-idig_count_records.R

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ recordset <- "7450a9e3-ef95-4f9e-8260-09b498d2c5e6"
44

55
test_that("all records is a large number", {
66
testthat::skip_on_cran()
7+
testthat::skip_if_offline()
8+
79
num <- idig_count_records()
810

911
expect_that(num, is_a("integer"))
@@ -13,6 +15,8 @@ test_that("all records is a large number", {
1315

1416
test_that("rq searches on the endpoint is a small number", {
1517
testthat::skip_on_cran()
18+
testthat::skip_if_offline()
19+
1620
num <- idig_count_records(rq = list("recordset" = recordset))
1721

1822
expect_that(num, is_a("integer"))

tests/testthat/test-idig_meta_fields.R

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ context("test idig_meta_fields")
22

33
test_that("records field list returns", {
44
testthat::skip_on_cran()
5+
testthat::skip_if_offline()
6+
57
f <- idig_meta_fields()
68

79
expect_that(f, is_a("list"))
@@ -12,6 +14,8 @@ test_that("records field list returns", {
1214

1315
test_that("records indexed subset returns", {
1416
testthat::skip_on_cran()
17+
testthat::skip_if_offline()
18+
1519
f <- idig_meta_fields(subset = "indexed")
1620

1721
expect_null(f[["data"]])
@@ -21,6 +25,8 @@ test_that("records indexed subset returns", {
2125

2226
test_that("records raw subset returns", {
2327
testthat::skip_on_cran()
28+
testthat::skip_if_offline()
29+
2430
f <- idig_meta_fields(subset = "raw")
2531

2632
expect_null(f[["uuid"]])
@@ -29,6 +35,8 @@ test_that("records raw subset returns", {
2935

3036
test_that("media list returns", {
3137
testthat::skip_on_cran()
38+
testthat::skip_if_offline()
39+
3240
f <- idig_meta_fields(type = "media")
3341

3442
expect_that(f, is_a("list"))
@@ -39,6 +47,8 @@ test_that("media list returns", {
3947

4048
test_that("media indexed subset returns", {
4149
testthat::skip_on_cran()
50+
testthat::skip_if_offline()
51+
4252
f <- idig_meta_fields(type = "media", subset = "indexed")
4353

4454
expect_null(f[["data"]])
@@ -48,6 +58,8 @@ test_that("media indexed subset returns", {
4858

4959
test_that("media raw subset returns", {
5060
testthat::skip_on_cran()
61+
testthat::skip_if_offline()
62+
5163
f <- idig_meta_fields(type = "media", subset = "raw")
5264

5365
expect_null(f[["uuid"]])

tests/testthat/test-idig_search_media.R

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ u <- "00d96710-77dd-492c-9d5c-095a8cf9ee5a"
1111

1212
test_that("full results for rq searches return", {
1313
testthat::skip_on_cran()
14+
testthat::skip_if_offline()
15+
1416
df <- idig_search_media(rq = rq, limit = 6000)
1517

1618
expect_that(df, is_a("data.frame"))
@@ -20,6 +22,8 @@ test_that("full results for rq searches return", {
2022

2123
test_that("full results for rq & mq queries together return", {
2224
testthat::skip_on_cran()
25+
testthat::skip_if_offline()
26+
2327
df <- idig_search_media(rq = rq, mq = mq, limit = 6000)
2428

2529
expect_that(df, is_a("data.frame"))
@@ -29,6 +33,8 @@ test_that("full results for rq & mq queries together return", {
2933

3034
test_that("full results for mq queries return", {
3135
testthat::skip_on_cran()
36+
testthat::skip_if_offline()
37+
3238
df <- idig_search_media(mq = mq, limit = 6000)
3339
u <- "00003b7d-07fb-4c36-a81a-18f7cde49203"
3440

@@ -41,6 +47,8 @@ test_that("full results for mq queries return", {
4147

4248
test_that("limits and custom fields return", {
4349
testthat::skip_on_cran()
50+
testthat::skip_if_offline()
51+
4452
df <- idig_search_media(mq = mq, fields = fields, limit = 10)
4553

4654
expect_true(nrow(df) == 10)

tests/testthat/test-idig_search_records.R

+16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ fields <- c("uuid", "genus", "specificepithet", "data.dwc:occurrenceID")
66

77
test_that("basic search, full results works", {
88
testthat::skip_on_cran()
9+
testthat::skip_if_offline()
10+
911
df <- idig_search_records(rq = rq, limit = 6000)
1012

1113
expect_that(df, is_a("data.frame"))
@@ -18,6 +20,8 @@ test_that("basic search, full results works", {
1820

1921
test_that("limited results, custom fields works", {
2022
testthat::skip_on_cran()
23+
testthat::skip_if_offline()
24+
2125
df <- idig_search_records(rq = rq, fields = fields, limit = 10)
2226

2327
expect_true(nrow(df) == 10)
@@ -29,6 +33,7 @@ test_that("limited results, custom fields works", {
2933

3034
test_that("offset works", {
3135
testthat::skip_on_cran()
36+
testthat::skip_if_offline()
3237

3338
df <- idig_search_records(rq = rq, fields = fields, limit = 2, offset = 0)
3439
second_uuid <- df[["uuid"]][[2]]
@@ -40,6 +45,8 @@ test_that("offset works", {
4045

4146
test_that("sorting works", {
4247
testthat::skip_on_cran()
48+
testthat::skip_if_offline()
49+
4350
df <- idig_search_records(rq = rq, fields = fields, limit = 1)
4451

4552
expect_true(substr(df[["uuid"]], 1, 2) == "00")
@@ -56,6 +63,7 @@ test_that("sorting works", {
5663

5764
test_that("max items disabled is thrown for large queries", {
5865
testthat::skip_on_cran()
66+
testthat::skip_if_offline()
5967

6068
expect_that(
6169
df <- idig_search_records(rq = list("country" = "united states")),
@@ -65,6 +73,7 @@ test_that("max items disabled is thrown for large queries", {
6573

6674
test_that("max items disabled is thrown for windows past 100k", {
6775
testthat::skip_on_cran()
76+
testthat::skip_if_offline()
6877

6978
expect_that(
7079
df <- idig_search_records(
@@ -77,6 +86,7 @@ test_that("max items disabled is thrown for windows past 100k", {
7786

7887
test_that("can get the 100000th result", {
7988
testthat::skip_on_cran()
89+
testthat::skip_if_offline()
8090

8191
df <- idig_search_records(
8292
rq = list("country" = "united states"),
@@ -87,13 +97,17 @@ test_that("can get the 100000th result", {
8797

8898
test_that("all fields returns a lot of fields", {
8999
testthat::skip_on_cran()
100+
testthat::skip_if_offline()
101+
90102
df <- idig_search_records(rq = rq, fields = "all", limit = 10)
91103

92104
expect_true(ncol(df) > 50)
93105
})
94106

95107
test_that("empty results return empty df with correct columns", {
96108
testthat::skip_on_cran()
109+
testthat::skip_if_offline()
110+
97111
df <- idig_search_records(rq = list("uuid" = "nobodyhome"), fields = fields)
98112

99113
expect_true(nrow(df) == 0)
@@ -102,6 +116,8 @@ test_that("empty results return empty df with correct columns", {
102116

103117
test_that("geopoint and special fields are expanded or excluded as appropriate", {
104118
testthat::skip_on_cran()
119+
testthat::skip_if_offline()
120+
105121
fields_special <- c("uuid", "geopoint", "mediarecords", "flags", "recordids")
106122
df <- idig_search_records(
107123
rq = list("uuid" = "f84faea8-82ac-4f71-b256-6b2be5d1b59d"),

0 commit comments

Comments
 (0)