Skip to content

Commit

Permalink
Replace str_to_lower in tests as well
Browse files Browse the repository at this point in the history
use pkg::func convention (#86) in this test as well
  • Loading branch information
damianooldoni committed Aug 5, 2022
1 parent b0c44fd commit dfbdb28
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions tests/testthat/test-output_gbif_get_taxa.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ testthat::test_that("output if taxon_keys is numeric", {
)
)
get_taxa_taxon_key_3 <- get_taxa_taxon_key_3 %>%
mutate(origin = str_to_lower(origin)) %>%
select(
dplyr::mutate(origin = tolower(origin)) %>%
dplyr::select(
key, scientificName, nubKey, taxonID, kingdom,
kingdomKey, datasetKey, constituentKey, origin
)

aa <- gbif_get_taxa(taxon_keys = 3, limit = 1)
aa <- aa %>%
mutate(origin = str_to_lower(origin)) %>%
select(
dplyr::mutate(origin = tolower(origin)) %>%
dplyr::select(
key, scientificName, nubKey, taxonID, kingdom,
kingdomKey, datasetKey, constituentKey, origin
)

expect_true(all(get_taxa_taxon_key_3 == aa, na.rm = TRUE))
testthat::expect_true(all(get_taxa_taxon_key_3 == aa, na.rm = TRUE))
})

testthat::test_that("output if taxon_keys is character", {
Expand All @@ -41,21 +41,21 @@ testthat::test_that("output if taxon_keys is character", {
)
)
get_taxa_taxon_key_2 <- get_taxa_taxon_key_2 %>%
mutate(origin = str_to_lower(origin)) %>%
select(
dplyr::mutate(origin = tolower(origin)) %>%
dplyr::select(
key, scientificName, nubKey, taxonID, kingdom,
kingdomKey, datasetKey, constituentKey, origin
)

aa <- gbif_get_taxa(taxon_keys = "2", limit = 1)
aa <- aa %>%
mutate(origin = str_to_lower(origin)) %>%
select(
dplyr::mutate(origin = tolower(origin)) %>%
dplyr::select(
key, scientificName, nubKey, taxonID, kingdom,
kingdomKey, datasetKey, constituentKey, origin
)

expect_true(all(get_taxa_taxon_key_2 == aa, na.rm = TRUE))
testthat::expect_true(all(get_taxa_taxon_key_2 == aa, na.rm = TRUE))
})

testthat::test_that("taxon_keys is (numeric) vector", {
Expand All @@ -67,21 +67,21 @@ testthat::test_that("taxon_keys is (numeric) vector", {
)
)
get_taxa_taxon_key_1_6 <- get_taxa_taxon_key_1_6 %>%
mutate(origin = str_to_lower(origin)) %>%
select(
dplyr::mutate(origin = tolower(origin)) %>%
dplyr::select(
key, scientificName, nubKey, taxonID, kingdom,
kingdomKey, datasetKey, constituentKey, origin
)

aa <- gbif_get_taxa(taxon_keys = c(1, 2, 3, 4, 5, 6))
aa <- aa %>%
mutate(origin = str_to_lower(origin)) %>%
select(
dplyr::mutate(origin = tolower(origin)) %>%
dplyr::select(
key, scientificName, nubKey, taxonID, kingdom,
kingdomKey, datasetKey, constituentKey, origin
)

expect_true(all(get_taxa_taxon_key_1_6 == aa, na.rm = TRUE))
testthat::expect_true(all(get_taxa_taxon_key_1_6 == aa, na.rm = TRUE))
})

testthat::test_that("taxon_keys is (character) vector", {
Expand All @@ -94,21 +94,21 @@ testthat::test_that("taxon_keys is (character) vector", {
)
)
get_taxa_taxon_key_char_vector <- get_taxa_taxon_key_char_vector %>%
mutate(origin = str_to_lower(origin)) %>%
select(
dplyr::mutate(origin = tolower(origin)) %>%
dplyr::select(
key, scientificName, nubKey, taxonID, kingdom,
kingdomKey, datasetKey, constituentKey, origin
)

aa <- gbif_get_taxa(taxon_keys = keys)
aa <- aa %>%
mutate(origin = str_to_lower(origin)) %>%
select(
dplyr::mutate(origin = tolower(origin)) %>%
dplyr::select(
key, scientificName, nubKey, taxonID, kingdom,
kingdomKey, datasetKey, constituentKey, origin
)

expect_true(all(
testthat::expect_true(all(
get_taxa_taxon_key_char_vector == aa,
na.rm = TRUE
))
Expand All @@ -124,21 +124,21 @@ testthat::test_that("limit < number of taxon_keys", {
)
)
get_taxa_taxon_key_lim_2 <- get_taxa_taxon_key_lim_2 %>%
mutate(origin = str_to_lower(origin)) %>%
select(
dplyr::mutate(origin = tolower(origin)) %>%
dplyr::select(
key, scientificName, nubKey, taxonID, kingdom,
kingdomKey, datasetKey, constituentKey, origin
)

aa <- gbif_get_taxa(taxon_keys = keys, limit = 2)
aa <- aa %>%
mutate(origin = str_to_lower(origin)) %>%
select(
dplyr::mutate(origin = tolower(origin)) %>%
dplyr::select(
key, scientificName, nubKey, taxonID, kingdom,
kingdomKey, datasetKey, constituentKey, origin
)

expect_true(all(get_taxa_taxon_key_lim_2 == aa, na.rm = TRUE))
testthat::expect_true(all(get_taxa_taxon_key_lim_2 == aa, na.rm = TRUE))
})

testthat::test_that("checklist is a character, valid limit", {
Expand All @@ -147,7 +147,7 @@ testthat::test_that("checklist is a character, valid limit", {
checklist_keys = "3f8a1297-3259-4700-91fc-acc4170b27ce",
limit = limit
)
expect_true(nrow(aa) == limit)
testthat::expect_true(nrow(aa) == limit)
})

testthat::test_that("checklist is a vector, valid limit", {
Expand All @@ -160,7 +160,7 @@ testthat::test_that("checklist is a vector, valid limit", {
checklist_keys = checklist_keys,
limit = limit
)
expect_true(nrow(aa) == limit * length(checklist_keys))
testthat::expect_true(nrow(aa) == limit * length(checklist_keys))
})

testthat::test_that("check single origin", {
Expand All @@ -169,24 +169,24 @@ testthat::test_that("check single origin", {
origin = "denormed_classification", limit = 10
)

expect_true(nrow(aa_denormed) == 10)
testthat::expect_true(nrow(aa_denormed) == 10)
})

testthat::test_that("check multiple origins", {
expect_warning(
testthat::expect_warning(
aa_origin <- gbif_get_taxa(
checklist_keys = "9ff7d317-609b-4c08-bd86-3bc404b77c42",
origin = c("denormed_classification", "source"),
limit = 3000
)
)

expect_warning(
testthat::expect_warning(
aa <- gbif_get_taxa(
checklist_keys = "9ff7d317-609b-4c08-bd86-3bc404b77c42",
limit = 3000
)
)

expect_true(nrow(aa) == nrow(aa_origin))
testthat::expect_true(nrow(aa) == nrow(aa_origin))
})

0 comments on commit dfbdb28

Please sign in to comment.