tests/testthat/test-annotate_with_NCBI_taxid.R

testthat::skip_on_ci()
skip_if_not_installed("taxizedb")

test_that("Danio rerio sequential, length one, offline", {
  df <-annotate_with_NCBI_taxid(7955, "species", mode = "local")
  expect_identical(df$species[[1]], "Danio rerio")
})

test_that("Danio rerio & Phascolarctos cinereus sequential, length 2, offline", {
  df <- annotate_with_NCBI_taxid(c(7955, 38626), c("species", "phylum"),mode = "local")
  check <- c("Danio rerio", "Phascolarctos cinereus")
  df %>%
    dplyr::pull(species) %>%
    expect_setequal(check)
})

test_that("Danio rerio sequential all, offline", {
  annotate_with_NCBI_taxid(7955, mode = "local") %>%
    testthat::expect_error(NA)
})

testthat::skip_if_offline()
skip_if_not_installed("taxize")
test_that("Danio rerio sequential, length one, online", {
  df <- annotate_with_NCBI_taxid(7955, "species")
  df.check <- tibble::tibble(species = "Danio rerio", taxid = "7955")
  expect_identical(df, df.check)
})

test_that("Danio rerio & Phascolarctos cinereus sequential, length 2, online", {
  df <- annotate_with_NCBI_taxid(c(7955, 38626), c("species", "phylum"),  mode = "remote")
  check <- c("Danio rerio", "Phascolarctos cinereus")
  df %>%
    dplyr::pull(species) %>%
    expect_setequal(check)
})

test_that("Danio rerio sequential all, online", {
  annotate_with_NCBI_taxid(7955, mode = "remote") %>%
    testthat::expect_error(NA)
})
currocam/taxa2hmmer documentation built on April 10, 2022, 11:02 a.m.