1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 16:42:10 +02:00

global var fix

This commit is contained in:
2019-02-27 17:39:39 +01:00
parent 642f6571fe
commit 95c49fdf79
10 changed files with 314 additions and 299 deletions

View File

@ -28,26 +28,26 @@ test_that("EUCAST rules work", {
expect_identical(colnames(septic_patients),
colnames(suppressWarnings(eucast_rules(septic_patients))))
a <- data.frame(mo = c("KLEPNE", # Klebsiella pneumoniae
"PSEAER", # Pseudomonas aeruginosa
"ENTAER"), # Enterobacter aerogenes
a <- data.frame(mo = c("Klebsiella pneumoniae",
"Pseudomonas aeruginosa",
"Enterobacter aerogenes"),
amox = "-", # Amoxicillin
stringsAsFactors = FALSE)
b <- data.frame(mo = c("KLEPNE", # Klebsiella pneumoniae
"PSEAER", # Pseudomonas aeruginosa
"ENTAER"), # Enterobacter aerogenes
b <- data.frame(mo = c("Klebsiella pneumoniae",
"Pseudomonas aeruginosa",
"Enterobacter aerogenes"),
amox = "R", # Amoxicillin
stringsAsFactors = FALSE)
expect_identical(suppressWarnings(eucast_rules(a, "mo", info = FALSE)), b)
expect_identical(suppressWarnings(eucast_rules(a, "mo", info = TRUE)), b)
expect_identical(suppressWarnings(interpretive_reading(a, "mo", info = TRUE)), b)
a <- data.frame(mo = c("STAAUR", # Staphylococcus aureus
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
a <- data.frame(mo = c("Staphylococcus aureus",
"Streptococcus group A"),
coli = "-", # Colistin
stringsAsFactors = FALSE)
b <- data.frame(mo = c("STAAUR", # Staphylococcus aureus
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
b <- data.frame(mo = c("Staphylococcus aureus",
"Streptococcus group A"),
coli = "R", # Colistin
stringsAsFactors = FALSE)
expect_equal(suppressWarnings(eucast_rules(a, "mo", info = FALSE)), b)

View File

@ -78,10 +78,17 @@ test_that("mo_property works", {
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)
#expect_identical(df_sample %>% pull(mo) %>% mo_fullname(language = "en"),
# df_sample %>% pull(fullname))
# outcome of mo_fullname must always return the fullname from the data set
library(dplyr)
a <- microorganisms %>%
transmute(mo,
# fullname from the original data:
f1 = fullname,
# newly created fullname based on MO code:
f2 = mo_fullname(mo, language = "en")) %>%
filter(f1 != f2)
expect_equal(nrow(a), 0)
})