Skip to content

Commit

Permalink
tested .download.raw.met.module
Browse files Browse the repository at this point in the history
  • Loading branch information
meetagrawal09 committed May 27, 2024
1 parent 0254085 commit e50e009
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions base/workflow/tests/testthat/test.do_conversions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_that("`do_conversions` ", {

})
1 change: 1 addition & 0 deletions modules/data.atmosphere/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Suggests:
foreach,
furrr,
future,
mockery,
parallel,
PEcAn.settings,
progress,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
test_that("`.download.raw.met.module` throws an error if register$site is unknown", {
register <- list(scale = 'example')
expect_error(
.download.raw.met.module(dir = NULL, met = NULL, register = register, str_ns = NULL),
"Unknown register\\$scale"
)
})

test_that("`.download.raw.met.module` is able to call the right download function based on met value", {
mocked_res <- mockery::mock(10)
mockery::stub(.download.raw.met.module, 'PEcAn.DB::convert_input', mocked_res)
register <- list(scale = 'site')
res <- .download.raw.met.module(
dir = NULL,
met = 'ERA5',
register = register,
machine = NULL,
start_date = '2010-01-01',
end_date = '2010-01-01',
str_ns = NULL,
con = NULL,
input_met = NULL,
site.id = 1,
lat.in = 1,
lon.in = 1,
host = NULL,
site = NULL,
username = NULL,
dbparms = NULL)
args <- mockery::mock_args(mocked_res)
mockery::expect_called(mocked_res, 1)
expect_equal(res, 10)
expect_equal(args[[1]]$fcn, 'download.ERA5')
})
3 changes: 3 additions & 0 deletions modules/data.atmosphere/tests/testthat/test.met.process.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_that("`met.process` ", {

})

0 comments on commit e50e009

Please sign in to comment.