pharmaverse / sdtm.oak

An EDC and Data Standard agnostic SDTM data transformation engine that automates the transformation of raw clinical data in ODM format to SDTM based on standard mapping algorithms
https://pharmaverse.github.io/sdtm.oak/
Apache License 2.0
25 stars 7 forks source link

0063 Move examples for internal functions to unit tests #69

Closed ShiyuC closed 1 month ago

ShiyuC commented 1 month ago

This PR moves all the example sections for internal functions to unit tests. Closes #63

Please check off each taskbox as an acknowledgment that you completed the task or check off that it is not relevant to your Pull Request. This checklist is part of the Github Action workflows and the Pull Request will not be merged into the devel branch until you have checked off each task.

github-actions[bot] commented 1 month ago

Code Coverage

Package Line Rate Health
sdtm.oak 93%
Summary 93% (949 / 1022)
ShiyuC commented 1 month ago

@ramiromagno @edgar-manukyan May I request your review of this MR? Thanks in advance

ShiyuC commented 1 month ago

@ShiyuC: great job! Thank you so much.

I think the only remaining bit is really to fix the test failures from the testing of derive_blfl(). But I am guessing Kamil or Ram are better equipped to give you feedback here as they worked on this function.

And also still on derive_blfl(), I would convert expect_snapshot_error() to expect_snapshot(..., error = TRUE) as expect_snapshot_error() is under "questioning" status (check its documentation).

Test failures related to derive_blfl()

==> Testing R file using 'testthat'

ℹ Loading sdtm.oak
[ FAIL 8 | WARN 0 | SKIP 0 | PASS 7 ]

── Failure (test-derive_blfl.R:47:3): derive_blfl sdmt_in validations work ─────
Snapshot of `derive_blfl(...)` has changed:
old vs new
- Required variable `DOMAIN` is missing
+ Required variable `DOMAIN` is missing in `sdtm_in`

* Run testthat::snapshot_accept('derive_blfl') to accept the change.
* Run testthat::snapshot_review('derive_blfl') to interactively review the change.

── Failure (test-derive_blfl.R:58:3): derive_blfl sdmt_in validations work ─────
Snapshot of `derive_blfl(...)` has changed:
old vs new
- Required variables `oak_id`, `raw_source` and `patient_number` are missing
+ Required variables `oak_id`, `raw_source`, and `patient_number` are missing in `sdtm_in`

* Run testthat::snapshot_accept('derive_blfl') to accept the change.
* Run testthat::snapshot_review('derive_blfl') to interactively review the change.

── Failure (test-derive_blfl.R:74:3): derive_blfl sdmt_in validations work ─────
Snapshot of `derive_blfl(...)` has changed:
old vs new
- Required variables `VSORRES`, `VSSTAT`, `VSTESTCD` and `VSDTC` are missing
+ Required variables `VSORRES`, `VSSTAT`, `VSTESTCD`, and `VSDTC` are missing in `sdtm_in`

* Run testthat::snapshot_accept('derive_blfl') to accept the change.
* Run testthat::snapshot_review('derive_blfl') to interactively review the change.

Confirmed that the failed test will be addressed in a separate PR.

ShiyuC commented 1 month ago

@rammprasad I'm still not authorized to merge this PR after all conversations and conflicts are resolved.

galachad commented 1 month ago

@rammprasad I'm still not authorized to merge this PR after all conversations and conflicts are resolved.

@ShiyuC I will merge this PR, we can check in another one why.

kamilsi commented 1 month ago

EDIT: nevermind, I see that @galachad fixed this in https://github.com/pharmaverse/sdtm.oak/pull/73, thanks (and indeed it was caused by admiraldev)!

I think the only remaining bit is really to fix the test failures from the testing of derive_blfl(). But I am guessing Kamil or Ram are better equipped to give you feedback here as they worked on this function.

Hi @ramiromagno, the changes in test behavior are not justified by any codebase changes in this PR. Perhaps admiraldev was updated on the machine where the tests were run, allowing it to identify the object where the problem is detected. Regardless, these are good changes and should be accepted using testthat::snapshot_accept('derive_blfl').

Confirmed that the failed test will be addressed in a separate PR.

@ShiyuC which issue is that?