From 3dba6d922aa47d88daaf328f9beb0e3912477567 Mon Sep 17 00:00:00 2001 From: Ramiro Magno Date: Sat, 4 May 2024 01:23:27 +0100 Subject: [PATCH] Linting --- tests/testthat/test-assign_datetime.R | 56 +++++++++++++-------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/testthat/test-assign_datetime.R b/tests/testthat/test-assign_datetime.R index c9bf65c0..3eb117c0 100644 --- a/tests/testthat/test-assign_datetime.R +++ b/tests/testthat/test-assign_datetime.R @@ -2,33 +2,33 @@ test_that("assign_datetime: date and time conversion", { md1 <- tibble::tribble( ~oak_id, ~raw_source, ~patient_number, ~MDBDR, ~MDEDR, ~MDETM, - 1L, "MD1", 375, NA, NA, NA, - 2L, "MD1", 375, "15-Sep-20", NA, NA, - 3L, "MD1", 376, "17-Feb-21", "17-Feb-21", NA, - 4L, "MD1", 377, "4-Oct-20", NA, NA, - 5L, "MD1", 377, "20-Jan-20", "20-Jan-20", "10:00:00", - 6L, "MD1", 377, "UN-UNK-2019", "UN-UNK-2019", NA, - 7L, "MD1", 377, "20-UNK-2019", "20-UNK-2019", NA, - 8L, "MD1", 378, "UN-UNK-2020", "UN-UNK-2020", NA, - 9L, "MD1", 378, "26-Jan-20", "26-Jan-20", "07:00:00", - 10L, "MD1", 378, "28-Jan-20", "1-Feb-20", NA, - 11L, "MD1", 378, "12-Feb-20", "18-Feb-20", NA, - 12L, "MD1", 379, "10-UNK-2020", "20-UNK-2020", NA, - 13L, "MD1", 379, NA, NA, NA, - 14L, "MD1", 379, NA, "17-Feb-20", NA + 1L, "MD1", 375L, NA, NA, NA, + 2L, "MD1", 375L, "15-Sep-20", NA, NA, + 3L, "MD1", 376L, "17-Feb-21", "17-Feb-21", NA, + 4L, "MD1", 377L, "4-Oct-20", NA, NA, + 5L, "MD1", 377L, "20-Jan-20", "20-Jan-20", "10:00:00", + 6L, "MD1", 377L, "UN-UNK-2019", "UN-UNK-2019", NA, + 7L, "MD1", 377L, "20-UNK-2019", "20-UNK-2019", NA, + 8L, "MD1", 378L, "UN-UNK-2020", "UN-UNK-2020", NA, + 9L, "MD1", 378L, "26-Jan-20", "26-Jan-20", "07:00:00", + 10L, "MD1", 378L, "28-Jan-20", "1-Feb-20", NA, + 11L, "MD1", 378L, "12-Feb-20", "18-Feb-20", NA, + 12L, "MD1", 379L, "10-UNK-2020", "20-UNK-2020", NA, + 13L, "MD1", 379L, NA, NA, NA, + 14L, "MD1", 379L, NA, "17-Feb-20", NA ) - warning_msg <- "There were 12 parsing problems\\. Run `problems\\(\\)` on parsed results for details\\." - expect_warning( - rlang::with_interactive( - assign_datetime( - raw_dat = md1, - raw_var = c("MDEDR", "MDETM"), - raw_fmt = c("d-m-y", "H:M:S"), - raw_unk = c("UN", "UNK"), - tgt_var = "CMSTDTC" - ) - ), regexp = warning_msg) + warning_msg <- + "There were 12 parsing problems\\. Run `problems\\(\\)` on parsed results for details\\." + expect_warning(rlang::with_interactive( + assign_datetime( + raw_dat = md1, + raw_var = c("MDEDR", "MDETM"), + raw_fmt = c("d-m-y", "H:M:S"), + raw_unk = c("UN", "UNK"), + tgt_var = "CMSTDTC" + ) + ), regexp = warning_msg) # If not run interactively then warnings should not be raised. expect_silent( @@ -41,12 +41,12 @@ test_that("assign_datetime: date and time conversion", { ) ) - problems_index <- seq(1L, 14L)[-c(5, 9)] + problems_index <- seq(1L, 14L)[-c(5L, 9L)] problems <- tibble::tibble(..i = problems_index, MDEDR = md1$MDEDR[problems_index], MDETM = md1$MDETM[problems_index]) - CMSTDTC <- + cmstdtc <- structure( c( NA, @@ -71,7 +71,7 @@ test_that("assign_datetime: date and time conversion", { expected <- cm1 |> dplyr::select("oak_id", "raw_source", "patient_number") |> - dplyr::bind_cols(tibble::tibble(CMSTDTC = CMSTDTC)) + dplyr::bind_cols(tibble::tibble(CMSTDTC = cmstdtc)) expect_equal(object = cm1, expected = expected)