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 22, 2024
1 parent 3840a90 commit 0ac8168
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/testthat/_snaps/eff_models.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,38 @@
9 " 95% CI" <NA> "(-2.2;1.1)"
# ... with abbreviated variable name 1: `var1_Xanomeline High Dose`

---

WAoAAAACAAQCAwACAwAAAAMTAAAAAwAAABAAAAAJAAQACQAAAB1wLXZhbHVlKERvc2UgUmVz
cG9uc2UpIFsxXVsyXQAEAAkAAAAAAAQACQAAAB1wLXZhbHVlKFhhbiAtIFBsYWNlYm8pIFsx
XVszXQAEAAkAAAAXICBEaWZmIG9mIExTIE1lYW5zIChTRSkABAAJAAAACCAgOTUlIENJAAQA
CQAAAAAABAAJAAAAInAtdmFsdWUoWGFuIEhpZ2ggLSBYYW4gTG93KSBbMV1bM10ABAAJAAAA
FyAgRGlmZiBvZiBMUyBNZWFucyAoU0UpAAQACQAAAAggIDk1JSBDSQAAABAAAAAJAAQACQAA
AAJOQQAEAAkAAAACTkEABAAJAAAADCAgIDAuNTY5ICAgIAAEAAkAAAALLTAuNSAoMC44MikA
BAAJAAAACigtMi4xOzEuMSkABAAJAAAAAAAEAAkAAAACTkEABAAJAAAAAk5BAAQACQAAAAJO
QQAAABAAAAAJAAQACQAAAAwgICAwLjI0NSAgICAABAAJAAAAAAAEAAkAAAAMICAgMC4yMzMg
ICAgAAQACQAAAAstMS4wICgwLjg0KQAEAAkAAAAKKC0yLjc7MC43KQAEAAkAAAAAAAQACQAA
AAwgICAwLjUyMCAgICAABAAJAAAACy0wLjUgKDAuODQpAAQACQAAAAooLTIuMjsxLjEpAAAE
AgAAAAEABAAJAAAABWNsYXNzAAAAEAAAAAMABAAJAAAABnRibF9kZgAEAAkA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SBIaWdoIERvc2UAAAQCAAAAAQAE
AAkAAAAJcm93Lm5hbWVzAAAADQAAAAKAAAAA////9wAABAIAAAABAAQACQAAAAVjbGFzcwAA
ABAAAAADAAQACQAAAAZ0YmxfZGYABAAJAAAAA3RibAAEAAkAAAAKZGF0YS5mcmFtZQAAAP4=

Binary file added tests/testthat/adadas.xpt
Binary file not shown.
17 changes: 17 additions & 0 deletions tests/testthat/test-eff_models.r
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ test_that("Pilot3 can use the testthat 3e", {
expect_true(TRUE)
})
test_that("efficacy models works", {
#use DESCRIPTION file imports/suggests packages for pilot3utils environment
adas <- haven::read_xpt("./adadas.xpt")
adas <- adas %>%
filter(
EFFFL == "Y",
ITTFL == "Y",
PARAMCD == "ACTOT",
ANL01FL == "Y"
)
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 ",
Expand All @@ -15,5 +25,12 @@ test_that("efficacy models works", {
" 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)
expect_s3_class(model_portion, "tbl_df")
expect_s3_class(.data_model_portion, "tbl_df")
expect_snapshot_value(.data_model_portion, "serialize")
expect_snapshot_value(model_portion, "serialize")
expect_length(.data_model_portion, 3)
})

0 comments on commit 0ac8168

Please sign in to comment.