From 68e40ed59b503b091576fc71b6054f97fcdd3263 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Fri, 10 Nov 2023 16:43:01 +0100 Subject: [PATCH] add test for write.report --- .buildlibrary | 2 +- CITATION.cff | 2 +- DESCRIPTION | 2 +- README.md | 6 +++--- tests/testthat/test-readwritereport.R | 10 ++++++++++ 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 244a06ee..f88bf5d7 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '120229152' +ValidationKey: '120248823' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/CITATION.cff b/CITATION.cff index 7fc9c439..a8525d90 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,7 +2,7 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'magclass: Data Class and Tools for Handling Spatial-Temporal Data' -version: 6.11.2 +version: 6.11.3 date-released: '2023-11-10' abstract: Data class for increased interoperability working with spatial-temporal data together with corresponding functions and methods (conversions, basic calculations diff --git a/DESCRIPTION b/DESCRIPTION index 3a4e9117..da31bb3e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: magclass Title: Data Class and Tools for Handling Spatial-Temporal Data -Version: 6.11.2 +Version: 6.11.3 Date: 2023-11-10 Authors@R: c( person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = c("aut", "cre")), diff --git a/README.md b/README.md index 8469efe1..dcd439c9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Data Class and Tools for Handling Spatial-Temporal Data -R package **magclass**, version **6.11.2** +R package **magclass**, version **6.11.3** [![CRAN status](https://www.r-pkg.org/badges/version/magclass)](https://cran.r-project.org/package=magclass) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1158580.svg)](https://doi.org/10.5281/zenodo.1158580) [![R build status](https://github.com/pik-piam/magclass/workflows/check/badge.svg)](https://github.com/pik-piam/magclass/actions) [![codecov](https://codecov.io/gh/pik-piam/magclass/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/magclass) [![r-universe](https://pik-piam.r-universe.dev/badges/magclass)](https://pik-piam.r-universe.dev/builds) @@ -56,7 +56,7 @@ In case of questions / problems please contact Jan Philipp Dietrich , R package version 6.11.2, . +Dietrich J, Bodirsky B, Bonsch M, Humpenoeder F, Bi S, Karstens K, Leip D (2023). _magclass: Data Class and Tools for Handling Spatial-Temporal Data_. doi:10.5281/zenodo.1158580 , R package version 6.11.3, . A BibTeX entry for LaTeX users is @@ -65,7 +65,7 @@ A BibTeX entry for LaTeX users is title = {magclass: Data Class and Tools for Handling Spatial-Temporal Data}, author = {Jan Philipp Dietrich and Benjamin Leon Bodirsky and Markus Bonsch and Florian Humpenoeder and Stephen Bi and Kristine Karstens and Debbora Leip}, year = {2023}, - note = {R package version 6.11.2}, + note = {R package version 6.11.3}, doi = {10.5281/zenodo.1158580}, url = {https://github.com/pik-piam/magclass}, } diff --git a/tests/testthat/test-readwritereport.R b/tests/testthat/test-readwritereport.R index 7e3b0eab..6c32450d 100644 --- a/tests/testthat/test-readwritereport.R +++ b/tests/testthat/test-readwritereport.R @@ -112,3 +112,13 @@ test_that("read/write report works with braces", { df <- read.csv(f, sep = ";", stringsAsFactors = FALSE) expect_identical(df$Unit, "Mt CO2/yr") }) + +test_that("write report does not crash with only NAs", { + f <- tempfile() + foo <- new.magpie("DEU", c(2015, 2020), + "Emissions|CO2|Energy|Demand|Transportation (w/ bunkers) (Mt CO2/yr)", + fill = NA) + expect_identical(write.report(foo, f), data.table::data.table()) + expect_message(write.report(foo, f), + "magclass object contains only NAs, returning empty data table. No file was written.") +})