-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from mhpob/dev-rm-purrr
Remove `purrr` dependency
- Loading branch information
Showing
15 changed files
with
199 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ Imports: | |
jsonlite, | ||
lubridate, | ||
plotrix, | ||
purrr, | ||
raster, | ||
readxl, | ||
sf, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
test_that("converts number stored as text", { | ||
life_text <- convert_life_to_days("5") | ||
|
||
expect_equal(life_text, 5) | ||
expect_type(life_text, "integer") | ||
}) | ||
|
||
test_that("converts number stored as numeric", { | ||
life_numeric <- convert_life_to_days(5) | ||
|
||
expect_equal(life_numeric, 5) | ||
expect_type(life_numeric, "integer") | ||
}) | ||
|
||
test_that("strips 'days'", { | ||
life_days <- convert_life_to_days("10 days") | ||
|
||
expect_equal(life_days, 10) | ||
expect_type(life_days, "integer") | ||
}) | ||
|
||
test_that("errors if different unit", { | ||
expect_error( | ||
convert_life_to_days("10 weeks"), | ||
"Cannot convert 10 weeks to time days." | ||
) | ||
|
||
expect_error( | ||
convert_life_to_days("parsecs"), | ||
"Cannot convert parsecs to time days." | ||
) | ||
}) | ||
|
||
test_that("handles vectors", { | ||
expect_identical( | ||
convert_life_to_days(c("5", 5, "10 days")), | ||
as.integer(c(5, 5, 10)) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
test_that("converts M/MALE/Male/male and F/FEMALE/Female/female", { | ||
sex <- convert_sex(c( | ||
"M", "MALE", "Male", "male", | ||
"F", "FEMALE", "Female", "female" | ||
)) | ||
|
||
expect_identical(sex, c(rep("MALE", 4), rep("FEMALE", 4))) | ||
}) | ||
|
||
test_that("can handle a vector", { | ||
sex_vec <- convert_sex(c("FEMALE", "MALE")) | ||
|
||
expect_identical(sex_vec, c("FEMALE", "MALE")) | ||
expect_type(sex_vec, "character") | ||
}) | ||
|
||
test_that("handles missing values correctly", { | ||
sex_na <- convert_sex(NA) | ||
|
||
expect_identical(sex_na, NA) | ||
expect_type(sex_na, "logical") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
test_that("drops array", { | ||
expect_identical( | ||
extract_station("HFX_HFX028"), | ||
"HFX028" | ||
) | ||
}) | ||
|
||
test_that("handles vectors", { | ||
expect_identical( | ||
extract_station(c("HFX_HFX028", "WAKA_WAKA4")), | ||
c("HFX028", "WAKA4") | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
test_that("returns codemap", { | ||
expect_equal( | ||
get_codemap("A69-1601-12345"), | ||
"A69-1601" | ||
) | ||
}) | ||
|
||
test_that("handles vectors", { | ||
expect_identical( | ||
get_codemap(c("A69-1601-12345", "A69-1601-54321", "A69-1303-2222")), | ||
c("A69-1601", "A69-1601", "A69-1303") | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test_that("Tests TBD", { | ||
skip("Test needs to be created.") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
test_that("can be silenced", { | ||
expect_silent( | ||
query_worms_common("striped bass", silent = TRUE) | ||
) | ||
}) | ||
|
||
test_that("outputs url to console if not silenced", { | ||
expect_output( | ||
query_worms_common("weakfish"), | ||
"https://www.marinespecies.org/rest/AphiaRecordsByVernacular/weakfish" | ||
) | ||
}) | ||
|
||
test_that("encodes spaces in URL", { | ||
expect_output( | ||
query_worms_common("Atlantic sturgeon"), | ||
"%20" | ||
) | ||
}) | ||
|
||
test_that("returns list", { | ||
expect_type( | ||
query_worms_common("Atlantic cod", silent = TRUE), | ||
"list" | ||
) | ||
}) |