Skip to content

Commit

Permalink
extra tests. added warning for show_plot = T.
Browse files Browse the repository at this point in the history
  • Loading branch information
alastair rushworth committed Jun 18, 2019
1 parent 69d8583 commit 6132c28
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
2 changes: 1 addition & 1 deletion R/plot_depracted.R
@@ -1,5 +1,5 @@
plot_deprecated <- function(out){
message("The `show_plot = TRUE` is deprecated and will be removed in a future version. The `show_plot()` function should be used instead. For more info, check out the help file ?show_plot()")
warning("`show_plot = TRUE` is deprecated and will be removed in a future version. The `show_plot()` function should be used instead. For more info, check out the help file ?show_plot()")
out %>% show_plot()
}

2 changes: 2 additions & 0 deletions tests/testthat/test_inspect_na.R
Expand Up @@ -6,6 +6,8 @@ data("nasa", package = "dplyr")
data("band_instruments", package = "dplyr")
data("storms", package = "dplyr")
data(mtcars, airquality)
# add a logical column
starwars$mass_lg <- starwars$mass > 70

test_that("Output is a data frame", {
expect_is(inspect_na(mtcars), "data.frame")
Expand Down
47 changes: 36 additions & 11 deletions tests/testthat/test_show_plot.R
Expand Up @@ -5,7 +5,7 @@ data("starwars", package = "dplyr")
data("storms", package = "dplyr")
library(vdiffr)

test_that("inspect_cat plots", {
test_that("a", {
expect_doppelganger("Inspect-cat-starwars", starwars %>% inspect_cat %>% show_plot)
expect_doppelganger("Inspect-cat-starwars-card", starwars %>% inspect_cat %>% show_plot(high_cardinality = 1))
expect_doppelganger("Inspect-cat-starwars-labels", starwars %>% inspect_cat %>% show_plot(text_labels = FALSE))
Expand All @@ -24,7 +24,7 @@ test_that("inspect_cat plots", {
expect_doppelganger("Inspect-cat-storms_col_2", storms %>% inspect_cat %>% show_plot(col_palette = 2))
})

test_that("inspect_cor plots", {
test_that("b", {
expect_doppelganger("Inspect-cor-starwars", starwars %>% inspect_cor %>% show_plot)
expect_doppelganger("Inspect-cor-storms", storms %>% inspect_cor %>% show_plot)
expect_doppelganger("Inspect-cor-starwars2",
Expand All @@ -39,7 +39,7 @@ test_that("inspect_cor plots", {
expect_doppelganger("Inspect-cor-storms_alpha", storms %>% inspect_cor %>% show_plot(alpha = 0.1))
})

test_that("inspect_imb plots", {
test_that("c", {
expect_doppelganger("Inspect-imb-starwars", starwars %>% inspect_imb %>% show_plot)
expect_doppelganger("Inspect-imb-storms", storms %>% inspect_imb %>% show_plot)
expect_doppelganger("Inspect-imb-starwars2",
Expand All @@ -56,7 +56,7 @@ test_that("inspect_imb plots", {

})

test_that("inspect_mem plots", {
test_that("d", {
expect_doppelganger("Inspect-mem-starwars", starwars %>% inspect_mem %>% show_plot)
expect_doppelganger("Inspect-mem-storms", storms %>% inspect_mem %>% show_plot)
expect_doppelganger("Inspect-mem-starwars2",
Expand All @@ -71,7 +71,7 @@ test_that("inspect_mem plots", {

})

test_that("inspect_na plots", {
test_that("e", {
expect_doppelganger("Inspect-na-starwars", starwars %>% inspect_na %>% show_plot)
expect_doppelganger("Inspect-na-storms", storms %>% inspect_na %>% show_plot)
expect_doppelganger("Inspect-na-starwars2",
Expand All @@ -83,20 +83,45 @@ test_that("inspect_na plots", {
inspect_na(
storms %>% dplyr::select(-2) %>% dplyr::sample_n(100, replace = T)
) %>% show_plot)

})

test_that("inspect_num plots", {
# test_that("f", {
# expect_doppelganger("Inspect-types-starwars", starwars %>% inspect_types %>% show_plot)
# expect_doppelganger("Inspect-types-storms", storms %>% inspect_types %>% show_plot)
# expect_doppelganger("Inspect-types-starwars2",
# starwars %>%
# inspect_types(
# starwars %>% dplyr::select(-2) %>% dplyr::sample_n(100, replace = T)
# ) %>% show_plot)
# expect_doppelganger("Inspect-types-storms2",
# storms %>%
# inspect_types(
# storms %>% dplyr::select(-2) %>% dplyr::sample_n(100, replace = T)
# ) %>% show_plot)
# })

test_that("g", {
expect_warning(starwars %>% inspect_cat(show_plot = TRUE))
expect_warning(starwars %>% inspect_cor(show_plot = TRUE))
expect_warning(starwars %>% inspect_imb(show_plot = TRUE))
expect_warning(starwars %>% inspect_na(show_plot = TRUE))
expect_warning(starwars %>% inspect_types(show_plot = TRUE))
})


test_that("h", {
expect_doppelganger("Inspect-num-starwars", starwars %>% inspect_num %>% show_plot)
expect_doppelganger("Inspect-num-storms", storms %>% inspect_num %>% show_plot)
expect_doppelganger("Inspect-num-starwars2",
starwars %>%
expect_doppelganger("Inspect-num-starwars2",
starwars %>%
inspect_num(
starwars %>% dplyr::select(-2) %>% dplyr::sample_n(100, replace = T)
) %>% show_plot)
expect_doppelganger("Inspect-num-storms2", storms %>%
expect_doppelganger("Inspect-num-storms2", storms %>%
inspect_num(
storms %>% dplyr::select(-2) %>% dplyr::sample_n(100, replace = T)
) %>% show_plot)
expect_doppelganger("Inspect-num-storms_plot_layout", storms %>% inspect_num %>% show_plot(plot_layout = c(3, 4)))
expect_doppelganger("Inspect-num-storms_plot_layout", storms %>% inspect_num %>% show_plot(plot_layout = c(3, 4)))
})


8 changes: 8 additions & 0 deletions tests/testthat/test_z_helpers.R
Expand Up @@ -17,3 +17,11 @@ test_that("sumna", {
test_that("check_variance", {
expect_warning(check_variance(zx))
})

test_that("check_dfs", {
x <- list(a = c(1, 2), b = c("a", "b"))
expect_error(check_df_cols(x))
expect_silent(check_df_cols(mtcars))
y <- data.frame()
expect_error(check_df_cols(y))
})

0 comments on commit 6132c28

Please sign in to comment.