Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update green ci #928

Merged
merged 21 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ URL: https://github.com/insightsengineering/rtables,
https://insightsengineering.github.io/rtables/
BugReports: https://github.com/insightsengineering/rtables/issues
Depends:
formatters (>= 0.5.8),
formatters (>= 0.5.8.9006),
magrittr (>= 1.5),
methods,
R (>= 2.10)
Expand Down
3 changes: 2 additions & 1 deletion R/default_split_funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ select_all_levels <- new("AllLevelsSentinel")
#' @note
#' Analysis or summary functions for which the order matters should never be used within the tabulation framework.
#'
#' @examples
#' @examplesIf require(tibble)
#'
#' library(tibble)
#' combodf <- tribble(
#' ~valname, ~label, ~levelcombo, ~exargs,
Expand Down
4 changes: 3 additions & 1 deletion man/add_overall_level.Rd

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

9 changes: 3 additions & 6 deletions tests/testthat/setup-fakedata.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
## Loading relevant libraries for tests
library(testthat)
Melkiades marked this conversation as resolved.
Show resolved Hide resolved
library(xml2)
library(tibble)
require(tibble, quietly = TRUE)
library(rtables)
Melkiades marked this conversation as resolved.
Show resolved Hide resolved
library(dplyr)
require(dplyr, quietly = TRUE)

# # Load and flag for pdftools to check for it
# check_pdf <- require(pdftools)
Expand Down Expand Up @@ -164,9 +163,7 @@ tt_to_export <- export_fact()

# Creating data-set with wide content to test wrapping
tt_to_test_wrapping <- function() {
trimmed_data <- ex_adsl %>%
filter(SEX %in% c("M", "F")) %>%
filter(RACE %in% levels(RACE)[1:2])
trimmed_data <- ex_adsl[(ex_adsl$SEX %in% c("M", "F")) & c(ex_adsl$RACE %in% levels(ex_adsl$RACE)[1:2]), ]

levels(trimmed_data$ARM)[1] <- "Incredibly long column name to be wrapped"
levels(trimmed_data$ARM)[2] <- "This_should_be_somewhere_split"
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-as_html.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
context("Exporting to HTML")

test_that("as_html smoke test", {
require(xml2, quietly = TRUE)
skip_if_not_installed("xml2")

shajoezhu marked this conversation as resolved.
Show resolved Hide resolved
tmpf <- tempfile(fileext = ".html")

tbl <- tt_to_export()
Expand Down Expand Up @@ -114,6 +117,9 @@ test_that("as_html indentation is translated to rows with linebreaks", {
})

test_that("as_html expands or not newlines depending on expand_newlines", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")

# Table with both col/row names with newlines
iris_mod <- iris %>%
mutate(Species2 = as.factor(paste0("General", "\n ", as.character(Species)))) %>%
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-formatting.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ test_that("format_na_str functionality works in get_formatted_cells (i.e. printi
})

test_that("format and na_str inheritance", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")

# Test data
DM2 <- DM %>%
filter(ARM != levels(DM$ARM)[3]) %>%
Expand Down Expand Up @@ -163,6 +166,9 @@ test_that("format and na_str inheritance", {
# Get the ASCII table
result <- get_formatted_cells(tbl) # Main function

require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")

# Expected data-set is built with dplyr
expected <- DM2 %>%
dplyr::group_by(ARM) %>%
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-printing.R
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@ test_that("Cell and column label wrapping works in printing", {


test_that("row label indentation is kept even if there are newline characters", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")

ANL <- DM %>%
mutate(value = rnorm(n()), pctdiff = runif(n())) %>%
filter(ARM == "A: Drug X")
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-tab_afun_cfun.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
context("Analysis functions (afun)")

test_that(".spl_context contains information about the column split", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")

## Duplication hack -> This would need to use split_cols_by_multivar(...)
# Workaround for #690
DM_tmp <- DM %>%
Expand Down Expand Up @@ -39,6 +42,12 @@ test_that(".spl_context contains information about the column split", {
})

test_that(".spl_context and afun extra parameters contain information about combo counts", {
require(tibble, quietly = TRUE)
skip_if_not_installed("tibble")

require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")

## Fix for https://github.com/insightsengineering/rtables/issues/517
combodf <- tribble(
~valname, ~label, ~levelcombo, ~exargs,
Expand Down Expand Up @@ -217,6 +226,9 @@ test_that("Error localization for missing split variable when done in alt_count_
})

test_that("Error localization for missmatch split variable when done in alt_count_df", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")

afun_tmp <- function(x, .alt_df_row, .spl_context, ...) {
# Important check that order is aligned even if source levels are not
check_val <- unique(.alt_df_row$ARMCD)
Expand Down Expand Up @@ -281,6 +293,9 @@ test_that("Error localization for missmatch split variable when done in alt_coun
context("Content functions (cfun)")

test_that(".alt_df_row appears in cfun but not in afun.", {
require(dplyr, quietly = TRUE)
skip_if_not_installed("dplyr")

# Adding STRATA2 col to DM for alt_counts_df col split
alt_tmp <- DM %>% left_join(
ex_adsl %>%
Expand Down
Loading