1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 00:02:38 +02:00

unit tests

This commit is contained in:
2019-02-21 23:32:30 +01:00
parent bd2a256969
commit 6c542268be
16 changed files with 534 additions and 296 deletions

View File

@ -56,3 +56,9 @@ test_that("data sets are valid", {
})
test_that("creation of data sets is valid", {
DT <- make_DT()
expect_lt(nrow(DT[prevalence == 1]), nrow(DT[prevalence == 2]))
expect_lt(nrow(DT[prevalence == 2]), nrow(DT[prevalence == 3]))
})

View File

@ -35,6 +35,7 @@ test_that("as.mo works", {
expect_equal(as.character(as.mo("Escherichia coli")), "B_ESCHR_COL")
expect_equal(as.character(as.mo("Escherichia species")), "B_ESCHR")
expect_equal(as.character(as.mo("Escherichia")), "B_ESCHR")
expect_equal(as.character(as.mo("Esch spp.")), "B_ESCHR")
expect_equal(as.character(as.mo(" B_ESCHR_COL ")), "B_ESCHR_COL")
expect_equal(as.character(as.mo("e coli")), "B_ESCHR_COL") # not Campylobacter
expect_equal(as.character(as.mo("klpn")), "B_KLBSL_PNE")
@ -45,6 +46,7 @@ test_that("as.mo works", {
expect_equal(as.character(as.mo("L. pneumophila")), "B_LGNLL_PNE")
expect_equal(as.character(as.mo("Strepto")), "B_STRPT")
expect_equal(as.character(as.mo("Streptococcus")), "B_STRPT") # not Peptostreptoccus
expect_equal(as.character(as.mo("B_STRPTC")), "B_STRPT") # old MO code (<=v0.5.0)
expect_equal(as.character(as.mo(c("GAS", "GBS"))), c("B_STRPT_GRA", "B_STRPT_GRB"))
@ -80,6 +82,10 @@ test_that("as.mo works", {
"MRSA",
"VISA"))),
rep("B_STPHY_AUR", 8))
expect_identical(
as.character(
as.mo(c('EHEC', 'EPEC', 'EIEC', 'STEC', 'ATEC'))),
rep("B_ESCHR_COL", 5))
# unprevalent MO
expect_identical(
as.character(
@ -116,6 +122,7 @@ test_that("as.mo works", {
expect_identical(as.character(as.mo("STCPYO", Lancefield = TRUE)), "B_STRPT_GRA") # group A
expect_identical(as.character(as.mo("S. agalactiae", Lancefield = FALSE)), "B_STRPT_AGA")
expect_identical(as.character(as.mo("S. agalactiae", Lancefield = TRUE)), "B_STRPT_GRB") # group B
expect_identical(as.character(suppressWarnings(as.mo("estreptococos grupo B"))), "B_STRPT_GRB")
expect_identical(as.character(as.mo("S. equisimilis", Lancefield = FALSE)), "B_STRPT_DYS_EQU")
expect_identical(as.character(as.mo("S. equisimilis", Lancefield = TRUE)), "B_STRPT_GRC") # group C
# Enterococci must only be influenced if Lancefield = "all"
@ -229,4 +236,13 @@ test_that("as.mo works", {
# Salmonella (City) are all actually Salmonella enterica spp (City)
expect_equal(as.character(suppressMessages(as.mo("Salmonella Goettingen"))),
"B_SLMNL_ENT")
expect_equal(as.character(as.mo("Salmonella Group A")), "B_SLMNL")
# no virusses
expect_warning(as.mo("Virus"))
# summary
expect_equal(length(summary(septic_patients$mo)), 6)
expect_warning(as.mo("Cutibacterium"))
})

View File

@ -75,6 +75,9 @@ test_that("mo_property works", {
expect_identical(mo_property("E. coli", property = "species"),
mo_species("E. coli"))
expect_identical(suppressWarnings(mo_ref("Chlamydia psittaci")), "Page, 1968")
expect_identical(mo_ref("Chlamydophila psittaci"), "Everett et al., 1999")
# check vector with random values
#library(dplyr)
#df_sample <- AMR::microorganisms %>% sample_n(100)