1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 14:01:55 +02:00

more unit tests

This commit is contained in:
2018-07-30 00:57:49 +02:00
parent d0a115d995
commit 510e8f22aa
6 changed files with 52 additions and 4 deletions

View File

@ -16,7 +16,8 @@ test_that("EUCAST rules work", {
"ENTAER"), # Enterobacter aerogenes
amox = "R", # Amoxicillin
stringsAsFactors = FALSE)
expect_identical(EUCAST_rules(a, info = FALSE), b)
expect_warning(EUCAST_rules(a, info = FALSE))
expect_identical(suppressWarnings(EUCAST_rules(a, info = FALSE)), b)
expect_identical(suppressWarnings(interpretive_reading(a, info = TRUE)), b)
a <- data.frame(bactid =
@ -29,7 +30,7 @@ test_that("EUCAST rules work", {
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
coli = "R", # Colistin
stringsAsFactors = FALSE)
expect_equal(EUCAST_rules(a, info = FALSE), b)
expect_equal(suppressWarnings(EUCAST_rules(a, info = FALSE)), b)
})
test_that("MO properties work", {

View File

@ -66,5 +66,20 @@ test_that("frequency table works", {
pull(age) %>%
sort())
# check format
expect_identical(septic_patients %>%
freq(age) %>%
format() %>%
apply(2, class) %>%
unname(),
rep("character", 5))
# check tibble
expect_identical(septic_patients %>%
freq(age) %>%
as_tibble() %>%
class() %>%
.[1],
"tbl_df")
})

View File

@ -43,6 +43,25 @@ test_that("resistance works", {
expect_warning(susceptibility(as.character(septic_patients$amcl,
septic_patients$gent)))
# check for errors
expect_error(IR(septic_patients %>% select(amox, amcl)))
expect_error(IR("test", minimum = "test"))
expect_error(IR("test", as_percent = "test"))
expect_error(S("test", minimum = "test"))
expect_error(S("test", as_percent = "test"))
expect_error(S(septic_patients %>% select(amox, amcl)))
expect_error(S("R", septic_patients %>% select(amox, amcl)))
# check too low amount of isolates
expect_identical(IR(septic_patients$amox, minimum = nrow(septic_patients) + 1),
NA)
expect_identical(S(septic_patients$amox, minimum = nrow(septic_patients) + 1),
NA)
# warning for speed loss
expect_warning(S(septic_patients$amcl, as.character(septic_patients$gent)))
})
test_that("old rsi works", {
@ -129,4 +148,9 @@ test_that("prediction of rsi works", {
col_ab = "amox",
col_date = "NOT EXISTING COLUMN",
info = TRUE))
# almost all E. coli are mero S in the Netherlands :)
expect_error(resistance_predict(tbl = filter(septic_patients, bactid == "ESCCOL"),
col_ab = "mero",
col_date = "date",
info = TRUE))
})