Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check about non empty values in column station_col in get_cam_op() #258

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 10 additions & 0 deletions tests/testthat/test-get_cam_op.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ 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"))
# use_prefix must be TRUE or FALSE
Expand Down