From 2e98e4c0a71d62905d5477110513e2c37c713b6a Mon Sep 17 00:00:00 2001 From: mikejohnson51 Date: Wed, 19 Jul 2023 17:05:28 -0400 Subject: [PATCH] tweak tests --- tests/testthat/test-climateR.R | 46 +++++++++++++--------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/tests/testthat/test-climateR.R b/tests/testthat/test-climateR.R index c5093ca..5a0bdcf 100644 --- a/tests/testthat/test-climateR.R +++ b/tests/testthat/test-climateR.R @@ -47,12 +47,6 @@ test_that("climater_filter", { scenario = c('rcp45', 'rcp85'), startDate = "2079-10-01")), 6) - expect_warning(climater_filter(id = "bcca", - varname = c('pr', 'tasmax','tasmin'), - model = c("CSIRO-Mk3-6-0"), - scenario = c('rcp45', 'rcp85'), - startDate = "2079-10-01")) - expect_error(climater_filter(id = "bcca", varname = c('pr', 'tasmax','tasmin'), model = c("CSIRO-Mk3-6-0"), @@ -63,40 +57,42 @@ test_that("climater_filter", { test_that("TerraClim", { - out = getTerraClim( + + foco = getTerraClim( AOI = aoi_get("Fort Collins"), varname = "tmin", startDate = "2020-01-01" ) - expect_true(class(out) == "list") - expect_true(class(out[[1]]) == "SpatRaster") - expect_true(names(out) == "tmin") - expect_true(names(out[[1]]) == "tmin_2020-01-01_total") - expect_true(nrow(out[[1]]) == 5) - expect_true(ncol(out[[1]]) == 5) - expect_equal(nrow(getTerraClim( - AOI = aoi_get("Fort Collins"), - varname = "tmin", - dryrun = TRUE - )), 1) + expect_true(class(foco) == "list") + expect_true(class(foco[[1]]) == "SpatRaster") + expect_true(names(foco) == "tmin") + expect_true(names(foco[[1]]) == "tmin_2020-01-01_total") + expect_true(nrow(foco[[1]]) == 5) + expect_true(ncol(foco[[1]]) == 5) + # expect_equal(nrow(getTerraClim( + # AOI = aoi_get("Fort Collins"), + # varname = "tmin", + # dryrun = TRUE + # )), 1) - ex = extract_sites(out, geocode("Fort Collins", pt = TRUE), "request") + ex = extract_sites(foco, geocode("Fort Collins", pt = TRUE), "request") - expect_true(ex[[1]]$FortCollins == -7.2) + expect_true(round(ex[[1]]$FortCollins,1) == -7.2) expect_true(ex[[1]]$date == as.POSIXct("2020-01-01", tz = "UTC")) }) test_that("TerraClimNormals", { out = getTerraClimNormals( - AOI = aoi_get("Fort Collins"), + AOI = AOI::aoi_get("Fort Collins"), varname = "tmin", month = 4, dryrun = TRUE ) + expect_equal(nrow(out), 1) - out = getTerraClimNormals(AOI = aoi_get("Fort Collins"), + out = getTerraClimNormals(AOI = AOI::aoi_get("Fort Collins"), varname = "tmin", month = 4) @@ -437,12 +433,6 @@ test_that("Remote VRT", { }) -terra::rast('/Users/mjohnson/github/opendap.catalog/data-raw/ned/USGS_seamless_13.vrt') - -terra::rast('/vsicurl/https://prd-tnm.s3.amazonaws.com/StagedProducts/Elevation/13/TIFF/USGS_Seamless_DEM_13.vrt') - -terra::rast('/vsis3/nextgen-hydrofabric/DEM-products/USGS_seamless_13.vrt') - test_that("Livneh", { xx = getLivneh( AOI = aoi_get("Fort Collins"),