Skip to content

Commit

Permalink
Revert "options for strict tests; few enhancements (#241)"
Browse files Browse the repository at this point in the history
This reverts commit 384f941.
  • Loading branch information
donyunardi committed Mar 19, 2024
1 parent b05b7b1 commit d957c12
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 106 deletions.
9 changes: 4 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,18 @@ Suggests:
png,
rtables (>= 0.5.1),
testthat (>= 3.1.5),
tinytex,
withr (>= 2.0.0)
tinytex
VignetteBuilder:
knitr
RdMacros:
lifecycle
Config/Needs/verdepcheck: rstudio/bslib, mllg/checkmate, davidgohel/flextable,
Config/Needs/verdepcheck: rstudio/bslib, mllg/checkmate,
rstudio/htmltools, yihui/knitr, r-lib/lifecycle, r-lib/R6,
rstudio/rmarkdown, rstudio/shiny, dreamRs/shinybusy,
dreamRs/shinyWidgets, yaml=vubiostat/r-yaml, r-lib/zip,
rstudio/DT, yihui/formatR, tidyverse/ggplot2,
davidgohel/flextable, rstudio/DT, yihui/formatR, tidyverse/ggplot2,
deepayan/lattice, cran/png, insightsengineering/rtables,
r-lib/testthat, rstudio/tinytex, r-lib/withr
r-lib/testthat, rstudio/tinytex
Config/Needs/website: insightsengineering/nesttemplate
Encoding: UTF-8
Language: en-US
Expand Down
4 changes: 2 additions & 2 deletions R/Previewer.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ reporter_previewer_srv <- function(id,
function(input, output, session) {
ns <- session$ns

reset_report_button_srv("resetButtonPreviewer", reporter)
teal.reporter::reset_report_button_srv("resetButtonPreviewer", reporter)

output$encoding <- shiny::renderUI({
reporter$get_reactive_add_card()
Expand All @@ -106,7 +106,7 @@ reporter_previewer_srv <- function(id,
),
class = if (length(reporter$get_cards())) "" else "disabled"
),
reset_report_button_ui(ns("resetButtonPreviewer"), label = "Reset Report")
teal.reporter::reset_report_button_ui(ns("resetButtonPreviewer"), label = "Reset Report")
)
})

Expand Down
3 changes: 1 addition & 2 deletions R/SimpleReporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
#' @return `NULL`.
#'
#' @examples
#' library(shiny)
#' if (interactive()) {
#' library(shiny)
#'
#' shinyApp(
#' ui = fluidPage(simple_reporter_ui("simple")),
#' server = function(input, output, session) {
Expand Down
1 change: 1 addition & 0 deletions R/yaml_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ md_header <- function(x) {
#' @return `input` argument or the appropriate `logical` value.
#' @keywords internal
#' @examples
#'
#' conv_str_logi <- getFromNamespace("conv_str_logi", "teal.reporter")
#' conv_str_logi("TRUE")
#' conv_str_logi("True")
Expand Down
1 change: 1 addition & 0 deletions man/conv_str_logi.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/simple_reporter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions tests/testthat/setup-options.R

This file was deleted.

10 changes: 2 additions & 8 deletions tests/testthat/test-Archiver.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@ card2$append_text("Header 2 text", "header2")
card2$append_text("A paragraph of default text", "header2")
lyt <- rtables::analyze(rtables::split_rows_by(rtables::basic_table(), "Day"), "Ozone", afun = mean)
table_res2 <- rtables::build_table(lyt, airquality)
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
{
card2$append_table(table_res2)
card2$append_table(iris)
}
)
card2$append_table(table_res2)
card2$append_table(iris)

reporter <- Reporter$new()
reporter$append_cards(list(card1, card2))
Expand Down
6 changes: 1 addition & 5 deletions tests/testthat/test-Renderer.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ text_block1 <- TextBlock$new()$set_content("text")$set_style("header2")
text_block2 <- TextBlock$new()$set_content("text")
png_path <- system.file("img", "Rlogo.png", package = "png")
picture_block <- PictureBlock$new()$set_content(ggplot2::ggplot(iris))
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
table_block <- TableBlock$new()$set_content(iris)
)
table_block <- TableBlock$new()$set_content(iris)
newpage_block <- NewpageBlock$new()
blocks <- list(text_block1, text_block2, picture_block, table_block, newpage_block)

Expand Down
14 changes: 3 additions & 11 deletions tests/testthat/test-ReportCard.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,14 @@ testthat::test_that("append_text returns self", {
})

testthat::test_that("append_table accepts a data.frame", {
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
testthat::expect_no_error(
ReportCard$new()$append_table(iris)
)
testthat::expect_no_error(
ReportCard$new()$append_table(iris)
)
})

testthat::test_that("append_table returns self", {
card <- ReportCard$new()
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
testthat::expect_identical(card$append_table(iris), card)
)
testthat::expect_identical(card$append_table(iris), card)
})

testthat::test_that("append_plot returns self", {
Expand Down
16 changes: 5 additions & 11 deletions tests/testthat/test-Reporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ testthat::test_that("new returns an object of type Reporter", {
testthat::expect_true(inherits(Reporter$new(), "Reporter"))
})

card1 <- ReportCard$new()
card1 <- teal.reporter::ReportCard$new()

card1$append_text("Header 2 text", "header2")
card1$append_text("A paragraph of default text", "header2")
Expand All @@ -15,20 +15,14 @@ card1$append_plot(
ggplot2::geom_histogram()
)

card2 <- ReportCard$new()
card2 <- teal.reporter::ReportCard$new()

card2$append_text("Header 2 text", "header2")
card2$append_text("A paragraph of default text", "header2")
lyt <- rtables::analyze(rtables::split_rows_by(rtables::basic_table(), "Day"), "Ozone", afun = mean)
table_res2 <- rtables::build_table(lyt, airquality)
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
{
card2$append_table(table_res2)
card2$append_table(iris)
}
)
card2$append_table(table_res2)
card2$append_table(iris)

reporter <- Reporter$new()
reporter$append_cards(list(card1, card2))
Expand Down Expand Up @@ -57,7 +51,7 @@ testthat::test_that("get_blocks and get_cards return empty list by default", {
})

testthat::test_that("The deep copy constructor copies the content files to new files", {
card <- ReportCard$new()$append_plot(ggplot2::ggplot(iris))
card <- teal.reporter::ReportCard$new()$append_plot(ggplot2::ggplot(iris))
reporter <- Reporter$new()$append_cards(list(card))
reporter_copy <- reporter$clone(deep = TRUE)
original_content_file <- reporter$get_blocks()[[1]]$get_content()
Expand Down
42 changes: 7 additions & 35 deletions tests/testthat/test-TableBlock.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ testthat::test_that("new returns an object of type TableBlock", {

testthat::test_that("set_content accepts a table object", {
block <- TableBlock$new()
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
testthat::expect_no_error(block$set_content(iris))
)
testthat::expect_no_error(block$set_content(iris))
})

testthat::test_that("set_content asserts the argument is a plot", {
Expand All @@ -22,11 +18,7 @@ testthat::test_that("set_content asserts the argument is a plot", {

testthat::test_that("set_content returns the TableBlock object", {
block <- TableBlock$new()
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
testthat::expect_identical(block$set_content(iris), block)
)
testthat::expect_identical(block$set_content(iris), block)
})

testthat::test_that("get_content returns character(0) on a newly initialized TableBlock", {
Expand All @@ -36,31 +28,19 @@ testthat::test_that("get_content returns character(0) on a newly initialized Tab
temp_dir <- tempdir()

testthat::test_that("to_list returns a named list with a one field, a proper file name", {
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
block <- TableBlock$new()$set_content(iris)
)
block <- TableBlock$new()$set_content(iris)
testthat::expect_equal(block$to_list(temp_dir), list(basename = basename(block$get_content())))
})

# to_list
testthat::test_that("to_list returns a named list with a one field, a proper path", {
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
tblock <- TableBlock$new()$set_content(iris)
)
tblock <- TableBlock$new()$set_content(iris)
testthat::expect_identical(tblock$to_list(temp_dir), list(basename = basename(tblock$get_content())))
})

# from_list
testthat::test_that("from_list after to_list to save and retrive", {
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
tblock <- TableBlock$new()$set_content(iris)
)
tblock <- TableBlock$new()$set_content(iris)
testthat::expect_identical(
file.size(TableBlock$new()$from_list(
tblock$to_list(temp_dir),
Expand All @@ -72,11 +52,7 @@ testthat::test_that("from_list after to_list to save and retrive", {

testthat::test_that("set_content supports data.frame object", {
block <- TableBlock$new()
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
testthat::expect_no_error(block$set_content(iris))
)
testthat::expect_no_error(block$set_content(iris))
})

testthat::test_that("set_content supports rtables object", {
Expand All @@ -89,9 +65,5 @@ testthat::test_that("set_content supports rtables object", {
"range" = diff(range(x))
)
})
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
testthat::expect_no_error(block$set_content(rtables::build_table(l, iris)))
)
testthat::expect_no_error(block$set_content(rtables::build_table(l, iris)))
})
6 changes: 1 addition & 5 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ testthat::test_that("panel_item", {

testthat::test_that("to_flextable: supported class", {
data_frame <- data.frame(A = 1:3, B = 4:6)
# https://github.com/davidgohel/flextable/issues/600
withr::with_options(
opts_partial_match_old,
flextable_output <- to_flextable(data_frame)
)
flextable_output <- to_flextable(data_frame)
testthat::expect_s3_class(flextable_output, "flextable")
})

Expand Down

0 comments on commit d957c12

Please sign in to comment.