Skip to content

Commit

Permalink
feat: remove datanames from shinyttests2
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Nov 5, 2024
1 parent 7d12d67 commit 0335c66
Show file tree
Hide file tree
Showing 36 changed files with 130 additions and 230 deletions.
4 changes: 1 addition & 3 deletions tests/testthat/test-shinytest2-tm_a_gee.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ app_driver_tm_a_gee <- function() {
) %>%
droplevels()
})
datanames <- c("ADSL", "ADQS")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
Expand Down
7 changes: 2 additions & 5 deletions tests/testthat/test-shinytest2-tm_a_mmrm.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app_driver_tm_a_mmrm <- function(fit_model = TRUE) { # nolint: object_length.
app_driver_tm_a_mmrm <- function(fit_model = TRUE) {
arm_ref_comp <- list(
ARMCD = list(
ref = "ARM B",
Expand All @@ -20,10 +20,7 @@ app_driver_tm_a_mmrm <- function(fit_model = TRUE) { # nolint: object_length.
as.factor() #' making consecutive numeric factor
)
})

datanames <- c("ADSL", "ADQS")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

arm_var <- choices_selected(c("ARM", "ARMCD"), "ARM")

Expand Down
5 changes: 1 addition & 4 deletions tests/testthat/test-shinytest2-tm_g_barchart_simple.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ app_driver_tm_g_barchart_simple <- function() { # nolint: object_length.
!((AETOXGR == 1) & (AESEV == "MILD") & (ARM == "A: Drug X"))
)
})

datanames <- c("ADSL", "ADAE")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-shinytest2-tm_g_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ app_driver_tm_g_ci <- function() {
ADSL <- teal.data::rADSL
ADLB <- teal.data::rADLB
})
teal.data::datanames(data) <- c("ADSL", "ADLB")
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[c("ADSL", "ADLB")]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
modules = tm_g_ci(
Expand Down
24 changes: 10 additions & 14 deletions tests/testthat/test-shinytest2-tm_g_forest_rsp.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
app_driver_tm_g_forest_rsp <- function() {
data <- teal.data::teal_data() %>%
within({
library(dplyr)
library(tern)
ADSL <- teal.data::rADSL
ADRS <- teal.data::rADRS %>%
mutate(AVALC = d_onco_rsp_label(AVALC)) %>%
with_label("Character Result/Finding") %>%
filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
})

datanames <- c("ADSL", "ADRS")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
data <- within(teal.data::teal_data(), {
library(dplyr)
library(tern)
ADSL <- teal.data::rADSL
ADRS <- teal.data::rADRS %>%
mutate(AVALC = d_onco_rsp_label(AVALC)) %>%
with_label("Character Result/Finding") %>%
filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
})
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

arm_ref_comp <- list(
ARM = list(
Expand Down
7 changes: 2 additions & 5 deletions tests/testthat/test-shinytest2-tm_g_forest_tte.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
app_driver_tm_g_forest_tte <- function() { # nolint: object_length.
app_driver_tm_g_forest_tte <- function() {
data <- within(teal.data::teal_data(), {
ADSL <- teal.modules.clinical::tmc_ex_adsl
ADSL$RACE <- with_label(droplevels(ADSL$RACE), "Race")
ADTTE <- teal.modules.clinical::tmc_ex_adtte
})

datanames <- c("ADSL", "ADTTE")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

arm_ref_comp <- list(
ARM = list(
Expand Down
28 changes: 12 additions & 16 deletions tests/testthat/test-shinytest2-tm_g_ipp.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
app_driver_tm_g_ipp <- function() {
data <- teal.data::teal_data() %>%
within({
library(dplyr)
library(tern)
ADSL <- teal.data::rADSL %>%
slice(1:20) %>%
df_explicit_na()
ADLB <- teal.data::rADLB %>%
filter(USUBJID %in% ADSL$USUBJID) %>%
df_explicit_na() %>%
filter(AVISIT != "SCREENING")
})

datanames <- c("ADSL", "ADLB")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
data <- within(teal.data::teal_data(), {
library(dplyr)
library(tern)
ADSL <- teal.data::rADSL %>%
slice(1:20) %>%
df_explicit_na()
ADLB <- teal.data::rADLB %>%
filter(USUBJID %in% ADSL$USUBJID) %>%
df_explicit_na() %>%
filter(AVISIT != "SCREENING")
})
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
Expand Down
24 changes: 10 additions & 14 deletions tests/testthat/test-shinytest2-tm_g_km.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
app_driver_tm_g_km <- function() {
data <- teal.data::teal_data() %>%
within({
library(dplyr)
ADSL <- tmc_ex_adsl
ADTTE <- tmc_ex_adtte %>%
rename(
VALUE_UNIT = AVALU,
ANALYSIS_VAL = AVAL,
CENSORING = CNSR
)
})

datanames <- c("ADSL", "ADTTE")
teal.data::datanames(data) <- datanames
data <- within(teal.data::teal_data(), {
library(dplyr)
ADSL <- tmc_ex_adsl
ADTTE <- tmc_ex_adtte %>%
rename(
VALUE_UNIT = AVALU,
ANALYSIS_VAL = AVAL,
CENSORING = CNSR
)
})
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]

arm_ref_comp <- list(
Expand Down
5 changes: 1 addition & 4 deletions tests/testthat/test-shinytest2-tm_g_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ app_driver_tm_g_lineplot <- function() {
AVISIT == forcats::fct_reorder(AVISIT, AVISITN, min)
)
})

datanames <- c("ADSL", "ADLB")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
Expand Down
9 changes: 3 additions & 6 deletions tests/testthat/test-shinytest2-tm_g_pp_adverse_events.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
app_driver_tm_g_pp_adverse_events <- function() { # nolint: object_length
data <- teal.data::teal_data() |> within({
app_driver_tm_g_pp_adverse_events <- function() { # nolint: object_length.
data <- within(teal.data::teal_data(), {
library(nestcolor)
library(dplyr)

ADAE <- teal.data::rADAE
ADSL <- teal.data::rADSL %>% filter(USUBJID %in% ADAE$USUBJID)
})

teal.data::datanames(data) <- c("ADAE", "ADSL")
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[c("ADAE", "ADSL")]

teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
Expand Down
7 changes: 3 additions & 4 deletions tests/testthat/test-shinytest2-tm_g_pp_patient_timeline.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app_driver_tm_g_pp_patient_timeline <- function() { # nolint object_length
app_driver_tm_g_pp_patient_timeline <- function() { # nolint object_length.
data <- teal.data::teal_data()
data <- within(data, {
library(dplyr)
Expand All @@ -21,12 +21,11 @@ app_driver_tm_g_pp_patient_timeline <- function() { # nolint object_length
})

adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4")
teal.data::datanames(data) <- c("ADSL", "ADAE", "ADCM")
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[c("ADSL", "ADAE", "ADCM")]

teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]
teal.data::join_keys(data)["ADCM", "ADCM"] <- adcm_keys
teal.data::join_keys(data)["ADAE", "ADCM"] <- c("STUDYID", "USUBJID")


init_teal_app_driver(
data = data,
modules = tm_g_pp_patient_timeline(
Expand Down
8 changes: 3 additions & 5 deletions tests/testthat/test-shinytest2-tm_g_pp_therapy.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app_driver_tm_g_pp_therapy <- function() { # nolint: object_length.
app_driver_tm_g_pp_therapy <- function() {
data <- within(teal.data::teal_data(), {
ADCM <- teal.modules.clinical::tmc_ex_adcm
ADSL <- dplyr::filter(
Expand All @@ -23,10 +23,8 @@ app_driver_tm_g_pp_therapy <- function() { # nolint: object_length.
})

adcm_keys <- c("STUDYID", "USUBJID", "ASTDTM", "CMSEQ", "ATC1", "ATC2", "ATC3", "ATC4")
datanames <- c("ADSL", "ADCM")

teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]
teal.data::join_keys(data)["ADCM", "ADCM"] <- adcm_keys

init_teal_app_driver(
Expand Down Expand Up @@ -144,7 +142,7 @@ testthat::test_that(
# Test changing selection ------------------------------------

# Check if a new selection of input changes the plot and table without any validation errors.
test_different_selection <- function(input_name, input_id, new_value) { # nolint object_length
test_different_selection <- function(input_name, input_id, new_value) {
testthat::test_that(
sprintf(
"e2e - tm_g_pp_therapy: Selection of %s changes the plot and table without any validation errors.",
Expand Down
14 changes: 5 additions & 9 deletions tests/testthat/test-shinytest2-tm_g_pp_vitals.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
app_driver_tm_g_pp_vitals <- function() {
data <- teal.data::teal_data() %>%
within({
ADSL <- teal.data::rADSL
ADVS <- teal.data::rADVS
})

datanames <- c("ADSL", "ADVS")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
data <- within(teal.data::teal_data(), {
ADSL <- teal.data::rADSL
ADVS <- teal.data::rADVS
})
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
Expand Down
4 changes: 1 addition & 3 deletions tests/testthat/test-shinytest2-tm_t_abnormality.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ app_driver_tm_t_abnormality <- function() {
) %>% with_label("On Treatment Record Flag")
)
})
datanames <- c("ADSL", "ADLB")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
Expand Down
20 changes: 8 additions & 12 deletions tests/testthat/test-shinytest2-tm_t_abnormality_by_worst_grade.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
app_driver_tm_t_abnormality_by_worst_grade <- function() { # nolint: object_length
data <- teal.data::teal_data() %>%
within({
library(dplyr)
app_driver_tm_t_abnormality_by_worst_grade <- function() { # nolint: object_length.
data <- within(teal.data::teal_data(), {
library(dplyr)

ADSL <- teal.data::rADSL
ADLB <- teal.data::rADLB %>%
filter(!AVISIT %in% c("SCREENING", "BASELINE"))
})

datanames <- c("ADSL", "ADLB")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
ADSL <- teal.data::rADSL
ADLB <- teal.data::rADLB %>%
filter(!AVISIT %in% c("SCREENING", "BASELINE"))
})
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
Expand Down
14 changes: 5 additions & 9 deletions tests/testthat/test-shinytest2-tm_t_ancova.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
app_driver_tm_t_ancova <- function() {
data <- teal.data::teal_data() %>%
within({
ADSL <- tmc_ex_adsl
ADQS <- tmc_ex_adqs
})

datanames <- c("ADSL", "ADQS")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
data <- within(teal.data::teal_data(), {
ADSL <- tmc_ex_adsl
ADQS <- tmc_ex_adqs
})
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

arm_ref_comp <- list(
ARM = list(
Expand Down
26 changes: 11 additions & 15 deletions tests/testthat/test-shinytest2-tm_t_binary_outcome.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
app_driver_tm_t_binary_outcome <- function() {
data <- teal.data::teal_data() %>%
within({
library(dplyr)
ADSL <- teal.data::rADSL
ADRS <- teal.data::rADRS %>%
mutate(
AVALC = d_onco_rsp_label(AVALC) %>%
with_label("Character Result/Finding")
) %>%
filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
})

datanames <- c("ADSL", "ADRS")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
data <- within(teal.data::teal_data(), {
library(dplyr)
ADSL <- teal.data::rADSL
ADRS <- teal.data::rADRS %>%
mutate(
AVALC = d_onco_rsp_label(AVALC) %>%
with_label("Character Result/Finding")
) %>%
filter(PARAMCD != "OVRINV" | AVISIT == "FOLLOW UP")
})
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

arm_ref_comp <- list(
ARMCD = list(ref = "ARM B", comp = c("ARM A", "ARM C")),
Expand Down
4 changes: 1 addition & 3 deletions tests/testthat/test-shinytest2-tm_t_coxreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ app_driver_tm_t_coxreg <- function() {
ADSL <- teal.data::rADSL
ADTTE <- teal.data::rADTTE
})
datanames <- c("ADSL", "ADTTE")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

arm_ref_comp <- list(
ACTARMCD = list(
Expand Down
4 changes: 1 addition & 3 deletions tests/testthat/test-shinytest2-tm_t_events.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ app_driver_tm_t_events <- function() {
ADSL <- teal.data::rADSL
ADAE <- teal.data::rADAE
})
datanames <- c("ADSL", "ADAE")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
Expand Down
11 changes: 4 additions & 7 deletions tests/testthat/test-shinytest2-tm_t_events_by_grade.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
app_driver_tm_t_events_by_grade <- function() { # nolint: object_length
app_driver_tm_t_events_by_grade <- function() { # nolint: object_length.
data <- teal.data::teal_data()
data <- within(data, {
library(dplyr)

ADSL <- teal.data::rADSL
lbls_adae <- col_labels(teal.data::rADAE)
.lbls_adae <- col_labels(teal.data::rADAE)
ADAE <- teal.data::rADAE %>%
mutate_if(is.character, as.factor)
col_labels(ADAE) <- lbls_adae
col_labels(ADAE) <- .lbls_adae
})

datanames <- c("ADSL", "ADAE")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
Expand Down
5 changes: 1 addition & 4 deletions tests/testthat/test-shinytest2-tm_t_events_patyear.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ app_driver_tm_t_events_patyear <- function() {
mutate(is_event = CNSR == 0) %>%
mutate(n_events = as.integer(is_event))
})

datanames <- c("ADSL", "ADAETTE")
teal.data::datanames(data) <- datanames
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[datanames]
teal.data::join_keys(data) <- teal.data::default_cdisc_join_keys[names(data)]

init_teal_app_driver(
data = data,
Expand Down
Loading

0 comments on commit 0335c66

Please sign in to comment.