Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Suggests:
License: CC0
URL: https://github.com/DOI-USGS/sbtools, https://doi-usgs.github.io/sbtools/
BugReports: https://github.com/DOI-USGS/sbtools/issues
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
VignetteBuilder: knitr
Config/testthat/parallel: false
Config/testthat/edition: 3
Expand Down
20 changes: 16 additions & 4 deletions R/item_list_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,22 @@ get_facet_files <- function(item) {
lapply(x$files,
function(y, n) {

list(name = y$name,
size = y$size,
url = y$downloadUri,
facet_name = x$name)
out <- list(name = y$name,
size = y$size,
url = y$downloadUri,
facet_name = n)

if(!is.null(y$cuid)) {

out <- c(out,
list(cuid = y$cuid,
key = y$key,
title = y$title,
useForPreview = y$useForPreview))

}

out

}, n = x$name)

Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/test-list_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,21 @@ test_that("recursive file list works right", {
files <- item_list_files(item, recursive = TRUE)

expect_true(nrow(files) > 100)
})

test_that("cloud facets", {

skip_on_cran()

if(!sb_ping()) skip("sciencebase unavailable, tests won't work")

sbid <- "69330512d4be02765ea81805"

item <- item_get(sbid)

files <- item_list_files(sbid)

# verify that a cloud shapefile is in here
expect_true(any(sapply(attr(files, "cloud"), \(x) x$cuid != "" & grepl("shp", x$key))))

})
4 changes: 2 additions & 2 deletions tests/testthat/test_examples.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ test_that("basic examples work", {

expect_equal(length(query_sb_text('Lees Ferry')), 20)

expect_equal(length(item_list_children(item_get('5060b03ae4b00fc20c4f3c8b'))), 20)
expect_equal(length(item_list_children(item_get('6644ea91d34e1955f5a42b46'))), 4)

expect_equal(length(item_list_children(item_get('5060b03ae4b00fc20c4f3c8b'), limit = 5)), 5)
expect_equal(length(item_list_children(item_get('6644ea91d34e1955f5a42b46'), limit = 2)), 2)

expect_warning(query_sb("test"))

Expand Down
Loading