From c67d8405cd53f64a86620e695d8d1ea8faddaec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ver=C3=ADssimo?= <211358+averissimo@users.noreply.github.com> Date: Mon, 11 Nov 2024 11:05:23 +0000 Subject: [PATCH 1/2] Fixes `datanames()` assignment and re-adds test for deprecated function (#350) # Pull Request Part of #333 #### Changes description - Method was incorrectly overwriting the `teal_data` object with their own names - Adds test that will continue to test the functionality until it's removed from the framework Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com> --- R/deprecated.R | 2 +- tests/testthat/test-deprecated.R | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/test-deprecated.R diff --git a/R/deprecated.R b/R/deprecated.R index 97035fcd8..01d6f1548 100644 --- a/R/deprecated.R +++ b/R/deprecated.R @@ -377,7 +377,7 @@ datanames <- function(x) { "`datanames<-`()", details = "invalid to use `datanames()<-` or `names()<-` on an object of class `teal_data`. See ?names.teal_data" ) - names(x) + x } #' @rdname datanames diff --git a/tests/testthat/test-deprecated.R b/tests/testthat/test-deprecated.R new file mode 100644 index 000000000..7359e0ec7 --- /dev/null +++ b/tests/testthat/test-deprecated.R @@ -0,0 +1,34 @@ +testthat::describe("datanames deprecation: ", { + testthat::it("setter does nothing to object", { + td <- teal_data() |> + within({ + iris <- iris + mtcars <- mtcars + }) + + # ignore deprecation warnings + withr::local_options(lifecycle_verbosity = "quiet") + datanames(td) <- c("mtcars") + + testthat::expect_equal( + td, + teal_data() |> + within({ + iris <- iris + mtcars <- mtcars + }) + ) + }) + + testthat::it("getter returns same as `names()`", { + td <- teal_data() |> + within({ + iris <- iris + mtcars <- mtcars + }) + + # ignore deprecation warnings + withr::local_options(lifecycle_verbosity = "quiet") + testthat::expect_setequal(datanames(td), names(td)) + }) +}) From b3e5da33aac2bed51fdaae24d7ad75340d0f83b5 Mon Sep 17 00:00:00 2001 From: averissimo Date: Mon, 11 Nov 2024 11:06:16 +0000 Subject: [PATCH 2/2] [skip actions] Bump version to 0.6.0.9018 --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 14a406fe3..e30cf5365 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: teal.data Title: Data Model for 'teal' Applications -Version: 0.6.0.9017 -Date: 2024-11-08 +Version: 0.6.0.9018 +Date: 2024-11-11 Authors@R: c( person("Dawid", "Kaledkowski", , "dawid.kaledkowski@roche.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9533-457X")), diff --git a/NEWS.md b/NEWS.md index 765092fb9..0ec7d138a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# teal.data 0.6.0.9017 +# teal.data 0.6.0.9018 ### Breaking changes