Skip to content

Commit

Permalink
Add test for filtered dataset that can be read
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdesmet committed Oct 25, 2024
1 parent 8eda9ae commit 73b354a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# camtrapdp (development version)

* New function `write_camtrapdp()` writes a Camera Trap Data Package to disk as a datapackage.json and CSV files (#137).
* New function `write_camtrapdp()` writes a Camera Trap Data Package to disk as a `datapackage.json` and CSV files (#137).
* New function `write_eml()` transforms Camtrap DP metadata to EML (#99).
* New function `round_coordinates()` allows to fuzzy/generalize location information by rounding deployment `latitude` and `longitude`. It also updates `coordinateUncertainty` in the deployments and `coordinatePrecision` and spatial scope in the metadata (#106).
* New function `shift_time()` allows to shift/correct date-times in data and metadata for specified deploymentIDs and duration (#108).
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-write_camtrapdp.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ test_that("write_camtrapdp() writes datapackage.json and CSV files to a
expect_invisible(write_camtrapdp(x, temp_dir))
})

test_that("write_camtrapdp() writes a (filtered) dataset that can be read", {
skip_if_offline()
x <- example_dataset()
temp_dir <- file.path(tempdir(), "package")
on.exit(unlink(temp_dir, recursive = TRUE))
# Filter deployments and write to disk
write_camtrapdp(filter_deployments(x, deploymentID == "00a2c20d"), temp_dir)

expect_no_error(read_camtrapdp(file.path(temp_dir, "datapackage.json")))
x_written <- read_camtrapdp(file.path(temp_dir, "datapackage.json"))
expect_lt(nrow(deployments(x_written)), nrow(deployments(x)))
expect_lt(nrow(media(x_written)), nrow(media(x)))
expect_lt(nrow(observations(x_written)), nrow(observations(x)))
})

test_that("write_camtrapdp() writes the unaltered example dataset as is", {
skip_if_offline()
x <- example_dataset()
Expand Down

0 comments on commit 73b354a

Please sign in to comment.