From de5c82b5a6445f36b3885cd0fddd76593540ac3e Mon Sep 17 00:00:00 2001 From: David Blodgett Date: Thu, 8 Jan 2026 08:17:23 -0600 Subject: [PATCH 1/2] facets with cloud storage now work fixes #341 --- DESCRIPTION | 2 +- R/item_list_files.R | 20 ++++++++++++++++---- tests/testthat/test-list_files.R | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fe4b40e..cb4f9e0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/R/item_list_files.R b/R/item_list_files.R index 6969089..22d760c 100644 --- a/R/item_list_files.R +++ b/R/item_list_files.R @@ -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) diff --git a/tests/testthat/test-list_files.R b/tests/testthat/test-list_files.R index 7e30b96..3efe0e2 100644 --- a/tests/testthat/test-list_files.R +++ b/tests/testthat/test-list_files.R @@ -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)))) + }) \ No newline at end of file From 6ad4fa7a8698458841ab7ace4849a7d238771d79 Mon Sep 17 00:00:00 2001 From: David Blodgett Date: Thu, 8 Jan 2026 08:25:56 -0600 Subject: [PATCH 2/2] test fix --- tests/testthat/test_examples.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test_examples.R b/tests/testthat/test_examples.R index 3fbac19..520d6a0 100644 --- a/tests/testthat/test_examples.R +++ b/tests/testthat/test_examples.R @@ -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"))