mirror of
https://github.com/msberends/AMR.git
synced 2025-12-15 12:30:22 +01:00
fortify code with more tests
This commit is contained in:
@@ -14,18 +14,18 @@ test_that("guess_bactid works", {
|
||||
|
||||
test_that("first isolates work", {
|
||||
# septic_patients contains 1960 out of 2000 first isolates
|
||||
septic_ptns <- septic_patients
|
||||
expect_equal(sum(first_isolate(tbl = septic_ptns,
|
||||
#septic_ptns <- septic_patients
|
||||
expect_equal(sum(first_isolate(tbl = septic_patients,
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
col_bactid = "bactid",
|
||||
info = FALSE)), 1960)
|
||||
|
||||
# septic_patients contains 1962 out of 2000 first weighted isolates
|
||||
septic_ptns$keyab <- suppressWarnings(key_antibiotics(septic_ptns))
|
||||
# septic_patients contains 1962 out of 2000 first *weighted* isolates
|
||||
#septic_ptns$keyab <- suppressWarnings(key_antibiotics(septic_ptns))
|
||||
expect_equal(
|
||||
suppressWarnings(sum(
|
||||
first_isolate(tbl = septic_ptns,
|
||||
first_isolate(tbl = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
col_bactid = "bactid",
|
||||
@@ -33,4 +33,20 @@ test_that("first isolates work", {
|
||||
type = "keyantibiotics",
|
||||
info = TRUE))),
|
||||
1962)
|
||||
|
||||
# set 1500 random observations to be of specimen type 'Urine'
|
||||
random_rows <- sample(x = 1:2000, size = 1500, replace = FALSE)
|
||||
expect_lt(sum(
|
||||
first_isolate(tbl = mutate(septic_patients,
|
||||
specimen = if_else(row_number() %in% random_rows,
|
||||
"Urine",
|
||||
"Unknown")),
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
col_bactid = "bactid",
|
||||
col_specimen = "specimen",
|
||||
filter_specimen = "Urine",
|
||||
info = TRUE)),
|
||||
1501)
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user