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

Closes #2519 fix_param_tte: add test #2530

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

## Updates of Existing Functions

- `derive_param_tte()` now provides a useful error message if in
`event_conditions` or `censor_conditions` a dataset is referenced which is not
specified in `source_datasets`. (#2519)

## Breaking Changes

- The following function arguments are entering the next phase of the deprecation process: (#2487)
Expand Down
14 changes: 13 additions & 1 deletion tests/testthat/_snaps/derive_param_tte.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,19 @@
See error message below:
i In argument: `PARAM = past("Time to First", AEDECOD, "Adverse Event")`. Caused by error in `past()`: ! could not find function "past"

# list_tte_source_objects Test 13: error is issued if package does not exist
# derive_param_tte Test 13: error if dataset_name not in source_datsets

Code
derive_param_tte(dataset_adsl = adsl, start_date = TRTSDT, event_conditions = list(
death), censor_conditions = list(lstalv), source_datasets = list(adsl = adsl),
set_values_to = exprs(PARAMCD = "OS", PARAM = "Overall Survival"))
Condition
Error in `derive_param_tte()`:
! The dataset names must be included in the list specified for the `source_datasets` argument.
i Following names were provided by `source_datasets`: "adsl"
i But, `censor_conditions[[1]]$dataset_name = adls`

# list_tte_source_objects Test 14: error is issued if package does not exist

Code
list_tte_source_objects(package = "tte")
Expand Down
54 changes: 50 additions & 4 deletions tests/testthat/test-derive_param_tte.R
Original file line number Diff line number Diff line change
Expand Up @@ -885,18 +885,64 @@ test_that("derive_param_tte Test 12: test dataset and dynamic byvars populated",
)
})

## Test 13: error if dataset_name not in source_datsets ----
test_that("derive_param_tte Test 13: error if dataset_name not in source_datsets", {
adsl <- tibble::tribble(
~USUBJID, ~DTHFL, ~DTHDT, ~LSTALVDT, ~TRTSDT, ~TRTSDTF,
"03", "Y", ymd("2021-08-21"), ymd("2021-08-21"), ymd("2021-08-10"), NA,
"04", "N", NA, ymd("2021-05-24"), ymd("2021-02-03"), NA
) %>%
mutate(STUDYID = "AB42")

death <- event_source(
dataset_name = "adsl",
filter = DTHFL == "Y",
date = DTHDT,
set_values_to = exprs(
EVENTDESC = "DEATH",
SRCDOM = "ADSL",
SRCVAR = "DTHDT"
)
)

lstalv <- censor_source(
dataset_name = "adls",
date = LSTALVDT,
censor = 1,
set_values_to = exprs(
EVENTDESC = "LAST KNOWN ALIVE DATE",
SRCDOM = "ADSL",
SRCVAR = "LSTALVDT"
)
)

expect_snapshot(
derive_param_tte(
dataset_adsl = adsl,
start_date = TRTSDT,
event_conditions = list(death),
censor_conditions = list(lstalv),
source_datasets = list(adsl = adsl),
set_values_to = exprs(
PARAMCD = "OS",
PARAM = "Overall Survival"
)
),
error = TRUE
)
})

# list_tte_source_objects ----
## Test 13: error is issued if package does not exist ----
test_that("list_tte_source_objects Test 13: error is issued if package does not exist", {
## Test 14: error is issued if package does not exist ----
test_that("list_tte_source_objects Test 14: error is issued if package does not exist", {
expect_snapshot(
list_tte_source_objects(package = "tte"),
error = TRUE
)
})

## Test 14: expected objects produced ----
test_that("list_tte_source_objects Test 14: expected objects produced", {
## Test 15: expected objects produced ----
test_that("list_tte_source_objects Test 15: expected objects produced", {
expected_output <- tibble::tribble(
~object, ~dataset_name, ~filter,
"ae_ser_event", "adae", quote(TRTEMFL == "Y" & AESER == "Y"),
Expand Down
Loading