Skip to content

Commit

Permalink
remove interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
Melkiades committed Jul 18, 2024
1 parent b164d74 commit 2cd669b
Showing 1 changed file with 17 additions and 27 deletions.
44 changes: 17 additions & 27 deletions tests/testthat/test-utils_dim_control_and_checks.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
test_that("Checking that levels are reduced correctly for multiple variables with defaults", {
rlang::with_interactive(
expect_message(
out <- reduce_num_levels_in_df(random.cdisc.data::cadae, "AEDECOD"),
paste0(
"Reducing levels of random.cdisc.data::cadae for variable AEDECOD: ",
"keeping 6 levels out of 10 levels. Total rows kept \\(\\%\\): 63.3"
)
expect_message(
out <- reduce_num_levels_in_df(random.cdisc.data::cadae, "AEDECOD"),
paste0(
"Reducing levels of random.cdisc.data::cadae for variable AEDECOD: ",
"keeping 6 levels out of 10 levels. Total rows kept \\(\\%\\): 63.3"
)
)
expect_equal(length(levels(out$AEDECOD)), 6L)
Expand All @@ -16,23 +14,19 @@ test_that("Checking that levels are reduced correctly for multiple variables wit
})

test_that("reduce_num_levels_in_df(num_max_values) works", {
rlang::with_interactive(
expect_message(
out <- reduce_num_levels_in_df(random.cdisc.data::cadae, "AEDECOD", num_max_values = 5),
"keeping 5 levels out of 10 levels"
)
expect_message(
out <- reduce_num_levels_in_df(random.cdisc.data::cadae, "AEDECOD", num_max_values = 5),
"keeping 5 levels out of 10 levels"
)
expect_equal(length(levels(out$AEDECOD)), 5L)
})

test_that("reduce_num_levels_in_df(num_max_values, num_of_rare_values) works", {
cadae_tmp <- random.cdisc.data::cadae %>% mutate(AEDECOD = as.character(AEDECOD))
cadae_tmp$AEDECOD[1] <- "an_outlier"
rlang::with_interactive(
expect_message(
out <- reduce_num_levels_in_df(cadae_tmp, "AEDECOD", num_max_values = 5, num_of_rare_values = 2),
"keeping 5 levels out of 11 levels"
)
expect_message(
out <- reduce_num_levels_in_df(cadae_tmp, "AEDECOD", num_max_values = 5, num_of_rare_values = 2),
"keeping 5 levels out of 11 levels"
)

expect_equal(length(levels(out$AEDECOD)), 5L)
Expand All @@ -44,11 +38,9 @@ test_that("reduce_num_levels_in_df(num_max_values, num_of_rare_values) works", {
test_that("reduce_num_levels_in_df(add_specific_value) works", {
cadae_tmp <- random.cdisc.data::cadae %>% mutate(AEDECOD = as.character(AEDECOD))
cadae_tmp$AEDECOD[1] <- "an_outlier"
rlang::with_interactive(
expect_message(
out <- reduce_num_levels_in_df(cadae_tmp, "AEDECOD", num_max_values = 5, add_specific_value = "an_outlier"),
"keeping 6 levels out of 11 levels"
)
expect_message(
out <- reduce_num_levels_in_df(cadae_tmp, "AEDECOD", num_max_values = 5, add_specific_value = "an_outlier"),
"keeping 6 levels out of 11 levels"
)

expect_equal(length(levels(out$AEDECOD)), 6L)
Expand All @@ -60,11 +52,9 @@ test_that("reduce_num_levels_in_df(add_specific_value) works", {
test_that("reduce_num_levels_in_df(add_specific_value) works", {
cadae_tmp <- random.cdisc.data::cadae %>% mutate(AEDECOD = as.character(AEDECOD))
cadae_tmp$AEDECOD[1] <- "an_outlier"
rlang::with_interactive(
expect_message(
out <- reduce_num_levels_in_df(cadae_tmp, "AEDECOD", num_max_values = 5, keep_spec_rows = c(1, 4)),
"keeping 5 \\+ 1 \\(from keep_spec_rows\\)"
)
expect_message(
out <- reduce_num_levels_in_df(cadae_tmp, "AEDECOD", num_max_values = 5, keep_spec_rows = c(1, 4)),
"keeping 5 \\+ 1 \\(from keep_spec_rows\\)"
)

expect_equal(length(levels(out$AEDECOD)), 6L)
Expand Down

0 comments on commit 2cd669b

Please sign in to comment.