Skip to content

Commit

Permalink
Merge branch 'read-CamtrapDP-v1.0-rc.1' of https://github.com/inbo/ca…
Browse files Browse the repository at this point in the history
…mtraptor into read-CamtrapDP-v1.0-rc.1
  • Loading branch information
peterdesmet committed Jul 20, 2023
2 parents 33b88d9 + f33c4e9 commit d8c0ad7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions R/get_cam_op.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ get_cam_op <- function(package = NULL,
# check camera trap data package
package <- check_package(package, datapkg, "get_cam_op")

# Check that station_col is a single string
assertthat::assert_that(assertthat::is.string(station_col))
# Check that station_col is one of the columns in deployments
assertthat::assert_that(
station_col %in% names(package$data$deployments),
Expand Down
17 changes: 16 additions & 1 deletion tests/testthat/test-get_cam_op.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,23 @@ test_that("input camtrap dp is checked properly", {
expect_error(get_cam_op("aaa"))
# numeric instead of datapackage
expect_error(get_cam_op(1))
# station_col is not NA
expect_error(
get_cam_op(mica, station_col = NA),
regexp = "station_col is not a string (a length one character vector).",
fixed = TRUE)
# station_col is length 1
expect_error(
get_cam_op(mica, station_col = c("locationID","locationName")),
regexp = "station_col is not a string (a length one character vector).",
fixed = TRUE)
# station_col value is not a column of deployments
expect_error(get_cam_op(mica, station_col = "bla"))
expect_error(
get_cam_op(mica, station_col = "bla"),
regexp = paste("Station column name (`bla`) is not valid:",
"it must be one of the deployments column names."),
fixed = TRUE
)
# column specified by station_col contains empty values
mica_empty_location_name <- mica
mica_empty_location_name$data$deployments$locationName[2:3] <- NA
Expand Down

0 comments on commit d8c0ad7

Please sign in to comment.