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 #2495 adds unit test for restricted_imputed_dtc_dt() #2528

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<details>
<summary>Developer Notes</summary>

- Created unit tests for developer internal function `restricted_imputed_dtc_dt()` (#2495)
- Adopted `data-raw/data` R Package Convention (#2427)

</details>
Expand Down
67 changes: 66 additions & 1 deletion tests/testthat/test-derive_vars_dt.R
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,71 @@ test_that("compute_dtf Test 13: compute DTF", {
)
})

# restrict_imputed_dtc_dt ----
test_that("", {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Description please - unless there is reason??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this was a complete oversight, good catch

imputed_dtc <- impute_dtc_dt(
input,
min_dates = list(
c(
ymd("2019-07-06"),
ymd("2019-07-06"),
ymd("2019-07-06"),
ymd("2019-07-06"),
ymd("2019-07-06")
),
c(
ymd("2019-06-06"),
ymd("2019-06-06"),
ymd("2019-06-06"),
ymd("2019-06-06"),
ymd("2019-06-06")
)
),
highest_imputation = "Y",
date_imputation = "first"
)
restricted <- restrict_imputed_dtc_dt(
input,
imputed_dtc = imputed_dtc,
min_dates = list(
c(
ymd("2019-07-06"),
ymd("2019-07-06"),
ymd("2019-07-06"),
ymd("2019-07-06"),
ymd("2019-07-06")
),
c(
ymd("2019-06-06"),
ymd("2019-06-06"),
ymd("2019-06-06"),
ymd("2019-06-06"),
ymd("2019-06-06")
)
),
max_dates = list(
c(
ymd("2019-07-06"),
ymd("2019-07-06"),
ymd("2019-07-06"),
ymd("2019-07-06"),
ymd("2019-07-06")
),
c(
ymd("2019-06-06"),
ymd("2019-06-06"),
ymd("2019-06-06"),
ymd("2019-06-06"),
ymd("2019-06-06")
)
)
)
expect_equal(
restricted,
c("2019-07-18", "2019-06-06", "2019-06-06", "2019-07-06", "2019-06-06")
)
})

# derive_vars_dt ----

date <- tibble::tribble(
Expand Down Expand Up @@ -569,4 +634,4 @@ test_that("derive_vars_dt Test 24: Supplying both min/max dates for highest_impu
expect_dfs_equal(actual, expected, keys = c("ASTDT", "ASTDTF"))
})

rm(input, input_warnings)
rm(input, input_warnings, inputdt, inputdtc, date)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add issue in our Discussion to look at a way to adopt this in all our testing scripts? maybe it is already there!

Loading