From cc606affcf128df2a57ede8fc481c2d3ab6aa371 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Tue, 9 Jul 2024 13:43:42 -0500 Subject: [PATCH 1/2] test grouping only before tsibble 1.1.5 --- tests/testthat/test-as_tibble-decay.R | 1 + tests/testthat/test-methods-epi_df.R | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-as_tibble-decay.R b/tests/testthat/test-as_tibble-decay.R index d2248a6d..5a38f9b9 100644 --- a/tests/testthat/test-as_tibble-decay.R +++ b/tests/testthat/test-as_tibble-decay.R @@ -8,6 +8,7 @@ test_that("as_tibble checks an attr to avoid decay to tibble", { }) test_that("as_tibble ungroups if needed", { + skip_if(packageVersion("tsibble") > "1.1.4") edf <- jhu_csse_daily_subset %>% group_by(geo_value) # removes the grouped_df class expect_identical(class(as_tibble(edf)), c("tbl_df", "tbl", "data.frame")) diff --git a/tests/testthat/test-methods-epi_df.R b/tests/testthat/test-methods-epi_df.R index b071d3ec..14924c22 100644 --- a/tests/testthat/test-methods-epi_df.R +++ b/tests/testthat/test-methods-epi_df.R @@ -121,7 +121,17 @@ test_that("Correct metadata when subset includes some of other_keys", { # Including both original other_keys was already tested above }) -test_that("Metadata and grouping are dropped by `as_tibble`", { +test_that("Metadata is dropped by `as_tibble`", { + grouped_converted <- toy_epi_df %>% + group_by(geo_value) %>% + as_tibble() + expect_true( + !any(c("metadata") %in% names(attributes(grouped_converted))) + ) +}) + +test_that("Grouping are dropped by `as_tibble`", { + skip_if(packageVersion("tsibble") > "1.1.4") grouped_converted <- toy_epi_df %>% group_by(geo_value) %>% as_tibble() From 25c9bbcdbc500d5c95ce605bb747ee0c7f439822 Mon Sep 17 00:00:00 2001 From: dsweber2 Date: Tue, 9 Jul 2024 14:06:19 -0500 Subject: [PATCH 2/2] documenting this change --- tests/testthat/test-as_tibble-decay.R | 1 + tests/testthat/test-methods-epi_df.R | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/testthat/test-as_tibble-decay.R b/tests/testthat/test-as_tibble-decay.R index 5a38f9b9..488ace63 100644 --- a/tests/testthat/test-as_tibble-decay.R +++ b/tests/testthat/test-as_tibble-decay.R @@ -8,6 +8,7 @@ test_that("as_tibble checks an attr to avoid decay to tibble", { }) test_that("as_tibble ungroups if needed", { + # tsibble is doing some method piracy, and overwriting as_tibble.grouped_df as of 1.1.5 skip_if(packageVersion("tsibble") > "1.1.4") edf <- jhu_csse_daily_subset %>% group_by(geo_value) # removes the grouped_df class diff --git a/tests/testthat/test-methods-epi_df.R b/tests/testthat/test-methods-epi_df.R index 14924c22..5ba66ed2 100644 --- a/tests/testthat/test-methods-epi_df.R +++ b/tests/testthat/test-methods-epi_df.R @@ -131,6 +131,7 @@ test_that("Metadata is dropped by `as_tibble`", { }) test_that("Grouping are dropped by `as_tibble`", { + # tsibble is doing some method piracy, and overwriting as_tibble.grouped_df as of 1.1.5 skip_if(packageVersion("tsibble") > "1.1.4") grouped_converted <- toy_epi_df %>% group_by(geo_value) %>%