mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 04:42:22 +02:00
CI tests
This commit is contained in:
@ -33,6 +33,9 @@ test_that("EUCAST rules work", {
|
||||
"reference.rule", "reference.rule_group"))
|
||||
|
||||
expect_error(suppressWarnings(eucast_rules(septic_patients, col_mo = "Non-existing")))
|
||||
expect_error(eucast_rules(x = "text"))
|
||||
expect_error(eucast_rules(data.frame(a = "test")))
|
||||
expect_error(eucast_rules(data.frame(mo = "test"), rules = "invalid rules set"))
|
||||
|
||||
expect_identical(colnames(septic_patients),
|
||||
colnames(suppressWarnings(eucast_rules(septic_patients))))
|
||||
|
@ -42,3 +42,10 @@ test_that("functions missing in older R versions work", {
|
||||
expect_equal(trimws(" test ", "l"), "test ")
|
||||
expect_equal(trimws(" test ", "r"), " test")
|
||||
})
|
||||
|
||||
test_that("looking up ab columns works", {
|
||||
expect_warning(generate_warning_abs_missing(c("AMP", "AMX")))
|
||||
expect_warning(generate_warning_abs_missing(c("AMP", "AMX"), any = TRUE))
|
||||
expect_warning(get_column_abx(septic_patients, hard_dependencies = "FUS"))
|
||||
expect_warning(get_column_abx(septic_patients, soft_dependencies = "FUS"))
|
||||
})
|
||||
|
@ -200,6 +200,9 @@ test_that("as.mo works", {
|
||||
expect_equal(suppressWarnings(as.character(as.mo("esco extra_text", allow_uncertain = FALSE))), "UNKNOWN")
|
||||
expect_equal(suppressWarnings(as.character(as.mo("esco extra_text", allow_uncertain = TRUE))), "B_ESCHR_COL")
|
||||
expect_warning(as.mo("esco extra_text", allow_uncertain = TRUE))
|
||||
expect_equal(suppressWarnings(as.character(as.mo("unexisting aureus", allow_uncertain = 3))), "B_STPHY_AUR")
|
||||
expect_equal(suppressWarnings(as.character(as.mo("unexisting staphy", allow_uncertain = 3))), "B_STPHY")
|
||||
expect_equal(suppressWarnings(as.character(as.mo("Staphylococcus aureus unexisting", allow_uncertain = 3))), "B_STPHY")
|
||||
|
||||
# predefined reference_df
|
||||
expect_equal(as.character(as.mo("TestingOwnID",
|
||||
@ -244,4 +247,20 @@ test_that("as.mo works", {
|
||||
# summary
|
||||
expect_equal(length(summary(septic_patients$mo)), 6)
|
||||
|
||||
# other
|
||||
expect_equal(as.character(as.mo(c("xxx", "con", "na", "nan"), debug = TRUE)),
|
||||
rep(NA_character_, 4))
|
||||
|
||||
expect_equal(as.character(as.mo(c("other", "none", "unknown"))),
|
||||
rep("UNKNOWN", 3))
|
||||
|
||||
expect_null(mo_failures())
|
||||
expect_true(septic_patients %>% pull(mo) %>% is.mo())
|
||||
|
||||
expect_equal(get_mo_code("test", "mo"), "test")
|
||||
expect_equal(length(get_mo_code("Escherichia", "genus")),
|
||||
nrow(AMR::microorganisms[base::which(AMR::microorganisms[, "genus"] %in% "Escherichia"),]))
|
||||
|
||||
expect_error(translate_allow_uncertain(5))
|
||||
|
||||
})
|
||||
|
@ -31,6 +31,7 @@ test_that("mo_property works", {
|
||||
expect_equal(mo_species("E. coli"), "coli")
|
||||
expect_equal(mo_subspecies("E. coli"), "")
|
||||
expect_equal(mo_fullname("E. coli"), "Escherichia coli")
|
||||
expect_equal(mo_name("E. coli"), "Escherichia coli")
|
||||
expect_equal(mo_type("E. coli", language = "en"), "Bacteria")
|
||||
expect_equal(mo_gramstain("E. coli", language = "en"), "Gram negative")
|
||||
expect_equal(class(mo_taxonomy("E. coli")), "list")
|
||||
@ -47,6 +48,8 @@ test_that("mo_property works", {
|
||||
expect_equal(mo_shortname("S. agalac"), "S. agalactiae")
|
||||
expect_equal(mo_shortname("S. agalac", Lancefield = TRUE), "GBS")
|
||||
|
||||
expect_true(mo_url("Escherichia coli") %like% "www.catalogueoflife.org")
|
||||
|
||||
# test integrity
|
||||
MOs <- AMR::microorganisms
|
||||
expect_identical(MOs$fullname, mo_fullname(MOs$fullname, language = "en"))
|
||||
|
Reference in New Issue
Block a user