Skip to content

Commit

Permalink
Tidying commit using testthat(3e) snapshot feature to unit test the e…
Browse files Browse the repository at this point in the history
…fficacy models in pilot3utils.
  • Loading branch information
Robert Devine committed Feb 21, 2024
1 parent 3248283 commit 2f35244
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/testthat/_snaps/eff_models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# efficacy models works

Code
efficacy_models(adas, "CHG", 24)
Output
# A tibble: 9 x 3
row_label `var1_Xanomeline Low Dose` var1_Xanomel~1
<chr> <chr> <chr>
1 "p-value(Dose Response) [1][2]" <NA> " 0.245 "
2 "" <NA> ""
3 "p-value(Xan - Placebo) [1][3]" " 0.569 " " 0.233 "
4 " Diff of LS Means (SE)" "-0.5 (0.82)" "-1.0 (0.84)"
5 " 95% CI" "(-2.1;1.1)" "(-2.7;0.7)"
6 "" "" ""
7 "p-value(Xan High - Xan Low) [1][3]" <NA> " 0.520 "
8 " Diff of LS Means (SE)" <NA> "-0.5 (0.84)"
9 " 95% CI" <NA> "(-2.2;1.1)"
# ... with abbreviated variable name 1: `var1_Xanomeline High Dose`

27 changes: 27 additions & 0 deletions tests/testthat/test-eff_models.r
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,30 @@ test_that("Pilot3 can use the testthat 3e", {
local_edition(3)
expect_true(TRUE)
})
test_that("efficacy models works", {
#use file path$adam settings from the ADRG and DESCRIPTION file imports/suggests packages pilot3utils environment
adas <- haven::read_xpt(file.path("~/pilot3-files/m5/datasets/rconsortiumpilot3/analysis/adam", "adadas.xpt"))
adas <- adas %>%
filter(
EFFFL == "Y",
ITTFL == "Y",
PARAMCD == "ACTOT",
ANL01FL == "Y"
)

Check warning on line 14 in tests/testthat/test-eff_models.r

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-eff_models.r,line=14,col=2,[indentation_linter] Indentation should be 4 spaces but is 2 spaces.
model_portion <- efficacy_models(adas, "CHG", 24)
.data_model_portion <- tibble::tribble(
~row_label, ~`~var1_Xanomeline Low Dose`, ~`~var1_Xanomeline High Dose`,
"p-value(Dose Response) [1][2]", "NA", " 0.245 ",
"", "NA", "",
"p-value(Xan - Placebo) [1][3]", " 0.569 ", " 0.233 ",
" Diff of LS Means (SE)", "-0.5 (0.82)", "-1.0 (0.84)",
" 95% CI", "(-2.1;1.1)", "(-2.7;0.7)",
"", "", "",
"p-value(Xan High - Xan Low) [1][3]", "NA", " 0.520 ",
" Diff of LS Means (SE)", "NA", "-0.5 (0.84)",
" 95% CI", "NA", "(-2.2;1.1)"
)
expect_equal(efficacy_models(adas, "CHG", 24), model_portion)
expect_snapshot(efficacy_models(adas, "CHG", 24), dplyr::select(model_portion))
expect_length(efficacy_models(adas, "CHG", 24), 3)
})

0 comments on commit 2f35244

Please sign in to comment.