Skip to content

Commit

Permalink
Merge pull request #137 from brazil-data-cube/b-0.9.2
Browse files Browse the repository at this point in the history
Update tests and fix typos
  • Loading branch information
OldLipe authored May 9, 2023
2 parents 5d5c1ef + c9e853c commit b9c33a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
6 changes: 2 additions & 4 deletions R/items-funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,9 @@ items_next.STACItemCollection <- function(items, ...) {
matched <- items_matched(items)

q <- doc_query(items)
if (is.null(q))
if (is.null(q)) {
.error("Cannot get next link URL", class = "next_error")
}

# get url of the next page
next_url <- Filter(function(x) x$rel == "next", items$links)
Expand Down Expand Up @@ -420,7 +421,6 @@ items_next.STACItemCollection <- function(items, ...) {

content <- post_request(next_stac, ..., encode = q$encode)
} else {

.error("Invalid HTTP method.")
}

Expand All @@ -430,15 +430,13 @@ items_next.STACItemCollection <- function(items, ...) {
# check pagination length
if (!is.null(q$params[["limit"]]) &&
items_length(content) > as.numeric(q$params[["limit"]])) {

.error("STAC invalid retrieved page length.")
}

# check if result length is valid
if (!is.null(matched) && !is.null(q$params[["limit"]]) &&
(items_length(content) != as.numeric(q$params[["limit"]])) &&
(items_length(content) + items_length(items) != matched)) {

.error("STAC pagination error.")
}

Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-signatures.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ testthat::test_that("signature functions", {
class = c("STACItemCollection", "RSTACDocument")
)

# provided wrong url
testthat::expect_error(
object = suppressWarnings(
items_sign(stac_items,
sign_fn = sign_planetary_computer(token_url = "test"))
)
)

# return the same object after signature?
testthat::expect_s3_class(
object = suppressWarnings(
Expand Down Expand Up @@ -123,12 +131,4 @@ testthat::test_that("signature functions", {
object = href_item,
regexp = "se"
)

# provided wrong url
testthat::expect_error(
object = suppressWarnings(
items_sign(stac_items,
sign_fn = sign_planetary_computer(token_url = "test"))
)
)
})

0 comments on commit b9c33a7

Please sign in to comment.