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

more unit tests

This commit is contained in:
2018-10-09 15:41:44 +02:00
parent 95c9fdc552
commit 67521394f6
4 changed files with 23 additions and 13 deletions

View File

@ -165,7 +165,15 @@ test_that("as.mo works", {
expect_equal(as.character(as.mo(c("TestingOwnID", "E. coli"),
reference_df = data.frame(a = "TestingOwnID", b = "B_ESCHR_COL"))),
c("B_ESCHR_COL", "B_ESCHR_COL"))
expect_warning(as.character(as.mo("TestingOwnID",
reference_df = NULL)))
expect_warning(as.mo("TestingOwnID", reference_df = NULL))
expect_error(as.mo("E. coli", reference_df = data.frame(a = "TestingOwnID")))
# combination of existing mo and certe
expect_identical(as.character(as.mo(c("B_ESCHR_COL", "ESCCOL"))),
c("B_ESCHR_COL", "B_ESCHR_COL"))
# TSN of prevalent and non prevalent ones
expect_equal(mo_TSN(c("Gomphosphaeria aponina delicatula", "Escherichia coli")),
c(717, 285))
})

View File

@ -12,6 +12,7 @@ test_that("mo_property works", {
expect_equal(mo_fullname("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(mo_TSN("E. coli"), 285)
expect_equal(class(mo_taxonomy("E. coli")), "list")
expect_equal(names(mo_taxonomy("E. coli")), c("subkingdom", "phylum", "class", "order",
"family", "genus", "species", "subspecies"))
@ -42,4 +43,14 @@ test_that("mo_property works", {
expect_error(mo_gramstain("E. coli", language = "UNKNOWN"))
# manual property function
expect_error(mo_property("E. coli", property = c("tsn", "fullname")))
expect_error(mo_property("E. coli", property = "UNKNOWN"))
expect_identical(mo_property("E. coli", property = "fullname"),
mo_fullname("E. coli"))
expect_identical(mo_property("E. coli", property = "genus"),
mo_genus("E. coli"))
expect_identical(mo_property("E. coli", property = "species"),
mo_species("E. coli"))
})