-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3192 from meetagrawal09/test-visualization
Improving test coverage for `PEcAn.visualization` package
- Loading branch information
Showing
7 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test_that("`add_icon()` able to create the correct output file", { | ||
withr::with_dir(tempdir(), { | ||
add_icon(1, 2, 3) | ||
# check if file exists | ||
expect_true(file.exists("Rplots.pdf")) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test_that("`plot_data()` able to create a new plot for data passed to it", { | ||
withr::with_dir(tempdir(), { | ||
res <- plot_data(data.frame(Y = c(1, 2), se = c(1,2), trt = c(1, 2)), base.plot = NULL, ymax = 10) | ||
print(res) | ||
expect_true(file.exists(paste0(getwd(), "/Rplots.pdf"))) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
test_that("`data.fetch()` able to return aggregated data with the correct label", { | ||
nc <- ncdf4::nc_open("./data/urbana_subdaily_test.nc") | ||
on.exit(ncdf4::nc_close(nc)) | ||
|
||
res <- data.fetch("time", nc, mean) | ||
expect_equal(attr(res, "lbl"), "days since 1700-01-01T00:00:00Z") | ||
|
||
res <- data.fetch("air_temperature", nc, mean) | ||
expect_equal(attr(res, "lbl"), "3-hourly Air Temperature at 2m in K") | ||
}) | ||
|
||
test_that("`plot_netcdf()` able to correctly plot the netcdf file data and create the plot file at the desired location", { | ||
nc <- ncdf4::nc_open("./data/urbana_subdaily_test.nc") | ||
withr::with_dir(tempdir(), { | ||
mockery::stub(plot_netcdf, 'ncdf4::nc_open', nc) | ||
res <- plot_netcdf("./data/urbana_subdaily_test.nc", "time", "air_temperature", year = 2010) | ||
|
||
# check if file exists | ||
expect_true(file.exists("Rplots.pdf")) | ||
}) | ||
}) |