-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
214 additions
and
0 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
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,52 @@ | ||
## Data for tests ---- | ||
|
||
df <- data.frame("crassula" = rep(1, 2), | ||
"dehiscens" = rep(1, 2)) | ||
|
||
|
||
## read_cpr_south_data() ---- | ||
|
||
test_that("Test read_cpr_south_data() for error", { | ||
|
||
create_tempdir() | ||
|
||
expect_error(read_cpr_south_data(version = "07"), | ||
paste0("The directory './forcis-db/version-07' does not exist. ", | ||
"Please check the argument 'path' or use the function ", | ||
"'download_forcis_db()'."), | ||
fixed = TRUE) | ||
|
||
dir.create(file.path("forcis-db", "version-07"), recursive = TRUE) | ||
|
||
expect_error(read_cpr_south_data(version = "07"), | ||
paste0("The South CPR dataset does not exist. Please use the ", | ||
"function 'download_forcis_db()'."), | ||
fixed = TRUE) | ||
}) | ||
|
||
test_that("Test read_cpr_south_data() for success", { | ||
|
||
create_tempdir() | ||
|
||
dir.create(file.path("forcis-db", "version-07"), recursive = TRUE) | ||
|
||
write.csv2(df, | ||
file = file.path("forcis-db", "version-07", | ||
"FORCIS_cpr_south_test.csv"), | ||
row.names = FALSE) | ||
|
||
x <- read_cpr_south_data(version = "07", check_for_update = FALSE) | ||
|
||
expect_equal(class(x), "data.frame") | ||
expect_equal(ncol(x), 3L) | ||
expect_equal(nrow(x), 2L) | ||
|
||
expect_true("data_type" %in% colnames(x)) | ||
expect_true("CPR South" %in% x$"data_type") | ||
|
||
expect_message({ x <- read_cpr_south_data(version = "07") }, | ||
paste0("A newer version of the FORCIS database is available. ", | ||
"Use 'download_forcis_db(version = NULL)' to download ", | ||
"it."), | ||
fixed = TRUE) | ||
}) |
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,52 @@ | ||
## Data for tests ---- | ||
|
||
df <- data.frame("crassula" = rep(1, 2), | ||
"dehiscens" = rep(1, 2)) | ||
|
||
|
||
## read_plankton_nets_data() ---- | ||
|
||
test_that("Test read_plankton_nets_data() for error", { | ||
|
||
create_tempdir() | ||
|
||
expect_error(read_plankton_nets_data(version = "07"), | ||
paste0("The directory './forcis-db/version-07' does not exist. ", | ||
"Please check the argument 'path' or use the function ", | ||
"'download_forcis_db()'."), | ||
fixed = TRUE) | ||
|
||
dir.create(file.path("forcis-db", "version-07"), recursive = TRUE) | ||
|
||
expect_error(read_plankton_nets_data(version = "07"), | ||
paste0("The Plankton net dataset does not exist. Please use the ", | ||
"function 'download_forcis_db()'."), | ||
fixed = TRUE) | ||
}) | ||
|
||
test_that("Test read_plankton_nets_data() for success", { | ||
|
||
create_tempdir() | ||
|
||
dir.create(file.path("forcis-db", "version-07"), recursive = TRUE) | ||
|
||
write.csv2(df, | ||
file = file.path("forcis-db", "version-07", | ||
"FORCIS_net_test.csv"), | ||
row.names = FALSE) | ||
|
||
x <- read_plankton_nets_data(version = "07", check_for_update = FALSE) | ||
|
||
expect_equal(class(x), "data.frame") | ||
expect_equal(ncol(x), 3L) | ||
expect_equal(nrow(x), 2L) | ||
|
||
expect_true("data_type" %in% colnames(x)) | ||
expect_true("Net" %in% x$"data_type") | ||
|
||
expect_message({ x <- read_plankton_nets_data(version = "07") }, | ||
paste0("A newer version of the FORCIS database is available. ", | ||
"Use 'download_forcis_db(version = NULL)' to download ", | ||
"it."), | ||
fixed = TRUE) | ||
}) |
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,52 @@ | ||
## Data for tests ---- | ||
|
||
df <- data.frame("crassula" = rep(1, 2), | ||
"dehiscens" = rep(1, 2)) | ||
|
||
|
||
## read_pump_data() ---- | ||
|
||
test_that("Test read_pump_data() for error", { | ||
|
||
create_tempdir() | ||
|
||
expect_error(read_pump_data(version = "07"), | ||
paste0("The directory './forcis-db/version-07' does not exist. ", | ||
"Please check the argument 'path' or use the function ", | ||
"'download_forcis_db()'."), | ||
fixed = TRUE) | ||
|
||
dir.create(file.path("forcis-db", "version-07"), recursive = TRUE) | ||
|
||
expect_error(read_pump_data(version = "07"), | ||
paste0("The Pump dataset does not exist. Please use the ", | ||
"function 'download_forcis_db()'."), | ||
fixed = TRUE) | ||
}) | ||
|
||
test_that("Test read_pump_data() for success", { | ||
|
||
create_tempdir() | ||
|
||
dir.create(file.path("forcis-db", "version-07"), recursive = TRUE) | ||
|
||
write.csv2(df, | ||
file = file.path("forcis-db", "version-07", | ||
"FORCIS_pump_test.csv"), | ||
row.names = FALSE) | ||
|
||
x <- read_pump_data(version = "07", check_for_update = FALSE) | ||
|
||
expect_equal(class(x), "data.frame") | ||
expect_equal(ncol(x), 3L) | ||
expect_equal(nrow(x), 2L) | ||
|
||
expect_true("data_type" %in% colnames(x)) | ||
expect_true("Pump" %in% x$"data_type") | ||
|
||
expect_message({ x <- read_pump_data(version = "07") }, | ||
paste0("A newer version of the FORCIS database is available. ", | ||
"Use 'download_forcis_db(version = NULL)' to download ", | ||
"it."), | ||
fixed = TRUE) | ||
}) |
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,52 @@ | ||
## Data for tests ---- | ||
|
||
df <- data.frame("crassula" = rep(1, 2), | ||
"dehiscens" = rep(1, 2)) | ||
|
||
|
||
## read_sediment_trap() ---- | ||
|
||
test_that("Test read_sediment_trap_data() for error", { | ||
|
||
create_tempdir() | ||
|
||
expect_error(read_sediment_trap_data(version = "07"), | ||
paste0("The directory './forcis-db/version-07' does not exist. ", | ||
"Please check the argument 'path' or use the function ", | ||
"'download_forcis_db()'."), | ||
fixed = TRUE) | ||
|
||
dir.create(file.path("forcis-db", "version-07"), recursive = TRUE) | ||
|
||
expect_error(read_sediment_trap_data(version = "07"), | ||
paste0("The Sediment trap dataset does not exist. Please use the ", | ||
"function 'download_forcis_db()'."), | ||
fixed = TRUE) | ||
}) | ||
|
||
test_that("Test read_sediment_trap_data() for success", { | ||
|
||
create_tempdir() | ||
|
||
dir.create(file.path("forcis-db", "version-07"), recursive = TRUE) | ||
|
||
write.csv2(df, | ||
file = file.path("forcis-db", "version-07", | ||
"FORCIS_trap_test.csv"), | ||
row.names = FALSE) | ||
|
||
x <- read_sediment_trap_data(version = "07", check_for_update = FALSE) | ||
|
||
expect_equal(class(x), "data.frame") | ||
expect_equal(ncol(x), 3L) | ||
expect_equal(nrow(x), 2L) | ||
|
||
expect_true("data_type" %in% colnames(x)) | ||
expect_true("Sediment trap" %in% x$"data_type") | ||
|
||
expect_message({ x <- read_sediment_trap_data(version = "07") }, | ||
paste0("A newer version of the FORCIS database is available. ", | ||
"Use 'download_forcis_db(version = NULL)' to download ", | ||
"it."), | ||
fixed = TRUE) | ||
}) |