From f537aaf1352113e7bfe47beb0db8634a5f0e88f5 Mon Sep 17 00:00:00 2001 From: Ben Raymond Date: Mon, 29 Jul 2024 16:04:46 +1000 Subject: [PATCH] fix tests, roxygenize v0.15.4 --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/oceandata.R | 2 +- man/bb_oceandata_cleanup.Rd | 20 ++++++++++++++++++++ tests/testthat/test_oceandata.R | 10 +++++----- 5 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 man/bb_oceandata_cleanup.Rd diff --git a/DESCRIPTION b/DESCRIPTION index bc295ee..3631abd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: bowerbird Type: Package Title: Keep a Collection of Sparkly Data Resources -Version: 0.15.3 +Version: 0.15.4 Authors@R: c(person("Ben", "Raymond", email = "ben.raymond@aad.gov.au", role = c("aut", "cre")), person("Michael", "Sumner", role = "aut"), person("Miles", "McBain", email = "miles.mcbain@gmail.com", role = c("rev", "ctb")), diff --git a/NAMESPACE b/NAMESPACE index 1655e3c..4d05d53 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -25,6 +25,7 @@ export(bb_handler_rget) export(bb_handler_wget) export(bb_install_wget) export(bb_modify_source) +export(bb_oceandata_cleanup) export(bb_rget) export(bb_rget_default_downloads) export(bb_settings) diff --git a/R/oceandata.R b/R/oceandata.R index b428ced..f67d811 100644 --- a/R/oceandata.R +++ b/R/oceandata.R @@ -106,7 +106,7 @@ bb_handler_oceandata_inner <- function(config, verbose = FALSE, local_dir_only = out <- file.path(out, "L3BIN") } ## time period, if it's specified in the search string - tp <- stringr::str_detect(src$method[[1]]$search, paste0("\\.", oceandata_alltp$abbrev, "\\.")) + tp <- stringr::str_detect(search, paste0("\\.", oceandata_alltp$abbrev, "\\.")) if (sum(tp, na.rm = TRUE) == 1) { out <- file.path(out, oceandata_alltp$time_period[which(tp)]) } diff --git a/man/bb_oceandata_cleanup.Rd b/man/bb_oceandata_cleanup.Rd new file mode 100644 index 0000000..dd2cbc8 --- /dev/null +++ b/man/bb_oceandata_cleanup.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/oceandata.R +\name{bb_oceandata_cleanup} +\alias{bb_oceandata_cleanup} +\title{Postprocessing: remove redundant NRT oceandata files} +\usage{ +bb_oceandata_cleanup(...) +} +\arguments{ +\item{...}{: extra parameters passed automatically by \code{bb_sync}} +} +\value{ +a list, with components \code{status} (TRUE on success) and \code{deleted_files} (character vector of paths of files that were deleted) +} +\description{ +This function is not intended to be called directly, but rather is specified as a \code{postprocess} option in \code{\link{bb_source}}. +} +\details{ +This function will remove near-real-time (NRT) files from an oceandata collection that have been superseded by their non-NRT versions. +} diff --git a/tests/testthat/test_oceandata.R b/tests/testthat/test_oceandata.R index 1a5f5f1..dfd95ed 100644 --- a/tests/testthat/test_oceandata.R +++ b/tests/testthat/test_oceandata.R @@ -18,7 +18,7 @@ test_that("bb_handler_oceandata works",{ data_group="Sea surface temperature") temp_root <- tempdir() ocf <- bb_add(bb_config(local_file_root=temp_root),ods) - expect_true(grepl("oceandata.sci.gsfc.nasa.gov/MODIST/Mapped$",bb_data_source_dir(ocf))) + expect_true(grepl("oceandata.sci.gsfc.nasa.gov/MODIST/Mapped/Monthly/9km$",bb_data_source_dir(ocf))) bb_sync(ocf, confirm_downloads_larger_than = NULL) fnm <- "oceandata.sci.gsfc.nasa.gov/MODIST/Mapped/Monthly/9km/par/TERRA_MODIS.20000301_20000331.L3m.MO.PAR.par.9km.nc" ## relative file name expect_true(file.exists(file.path(temp_root,fnm))) @@ -59,7 +59,7 @@ test_that("other oceandata handler tests", { user = "", password = "", warn_empty_auth = FALSE) temp_root <- tempdir() ocf <- bb_add(bb_config(local_file_root = temp_root), ods) - expect_true(grepl("oceandata.sci.gsfc.nasa.gov/MODISA/L3BIN$", bb_data_source_dir(ocf))) + expect_true(grepl("oceandata.sci.gsfc.nasa.gov/MODISA/L3BIN/Daily$", bb_data_source_dir(ocf))) ods <- bb_source(name="Oceandata VIIRS Level-3 binned daily RRS", id="VIIRS_L3b_DAY_SNPP_RRS", @@ -70,7 +70,7 @@ test_that("other oceandata handler tests", { method=list("bb_handler_oceandata", search = "SNPP_VIIRS*L3b.DAY.RRS.nc", sensor = "viirs", dtype = "L3b"), user = "", password = "", warn_empty_auth = FALSE) ocf <- bb_add(bb_config(local_file_root = temp_root), ods) - expect_true(grepl("oceandata.sci.gsfc.nasa.gov/VIIRS/L3BIN$", bb_data_source_dir(ocf))) + expect_true(grepl("oceandata.sci.gsfc.nasa.gov/VIIRS/L3BIN/Daily$", bb_data_source_dir(ocf))) ods <- bb_source(name="Oceandata MODIS Aqua Level-3 mapped daily 4km chl-a", id="MODISA_L3m_DAY_CHL_chlor_a_4km", @@ -81,7 +81,7 @@ test_that("other oceandata handler tests", { method=list("bb_handler_oceandata",search="AQUA_MODIS*L3m.DAY.CHL.chlor_a.4km.nc", sensor = "aqua", dtype = "L3m"), user = "", password = "", warn_empty_auth = FALSE) ocf <- bb_add(bb_config(local_file_root = temp_root), ods) - expect_true(grepl("oceandata.sci.gsfc.nasa.gov/MODISA/Mapped$", bb_data_source_dir(ocf))) + expect_true(grepl("oceandata.sci.gsfc.nasa.gov/MODISA/Mapped/Daily/4km$", bb_data_source_dir(ocf))) ods <- bb_source(name="Oceandata SeaWiFS Level-3 binned daily RRS", id="SeaWiFS_L3b_DAY_RRS", @@ -92,7 +92,7 @@ test_that("other oceandata handler tests", { method=list("bb_handler_oceandata",search="SEASTAR_SEAWIFS_GAC*L3b.DAY.RRS.nc", sensor = "seawifs", dtype = "L3b"), user = "", password = "", warn_empty_auth = FALSE) ocf <- bb_add(bb_config(local_file_root = temp_root), ods) - expect_true(grepl("oceandata.sci.gsfc.nasa.gov/SeaWiFS/L3BIN$", bb_data_source_dir(ocf))) + expect_true(grepl("oceandata.sci.gsfc.nasa.gov/SeaWiFS/L3BIN/Daily$", bb_data_source_dir(ocf))) }) test_that("bb_handler_oceandata works when no files match",{