From 470bf1c1f0cdfb301f52364dc3c9848b49dcfcd0 Mon Sep 17 00:00:00 2001 From: Damiano Oldoni Date: Fri, 29 Sep 2023 21:36:19 +0200 Subject: [PATCH 01/17] Add parsing issues to attributes dfs as problems --- R/read_camtrap_dp.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/read_camtrap_dp.R b/R/read_camtrap_dp.R index aea7e58b..8a8e3f03 100644 --- a/R/read_camtrap_dp.R +++ b/R/read_camtrap_dp.R @@ -168,7 +168,11 @@ read_camtrap_dp <- function(file = NULL, check_package(package, media = media) # Inherit parsing issues from reading + attr(package$data$deployments, which = "problems") <- issues_deployments attr(package$data$observations, which = "problems") <- issues_observations + if (media) { + attr(package$data$media, which = "problems") <- issues_media + } return(package) } From d653451b6cb4f01c50f04c2333df436211445ae7 Mon Sep 17 00:00:00 2001 From: Damiano Oldoni Date: Fri, 29 Sep 2023 21:36:39 +0200 Subject: [PATCH 02/17] Bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 41bdb40b..c386a999 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: camtraptor Title: Read, Explore and Visualize Camera Trap Data Packages -Version: 0.20.1 +Version: 0.20.2 Authors@R: c( person("Damiano", "Oldoni", email = "damiano.oldoni@inbo.be", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-3445-7562")), From 3a0414d4e2dbccfceb557f3144c2e036c9a3d431 Mon Sep 17 00:00:00 2001 From: Damiano Oldoni Date: Fri, 29 Sep 2023 21:58:00 +0200 Subject: [PATCH 03/17] Add tests for the dataframes with problems --- tests/testthat/test-read_camtrap_dp.R | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index 48cd60c8..1bd0eb3c 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -48,7 +48,6 @@ test_that("test warnings while reading files with parsing issues", { package = "camtraptor" ) w <- capture_warnings( - camtraptor::read_camtrap_dp(file = camtrap_dp_file_with_issues) ) # warning on deployments expect_equal( @@ -59,6 +58,12 @@ test_that("test warnings while reading files with parsing issues", { "`readr::problems()`." ) ) + problems_deploys <- readr::problems(dp_issues$data$deployments) + expect_equal(nrow(problems_deploys), 2) + expect_equal(problems_deploys$row, c(1,2)) + expect_equal(problems_deploys$col, c(7,7)) + expect_equal(problems_deploys$expected, rep("date like %Y-%m-%dT%H:%M:%S%z", 2)) + # warning on observations expect_equal( w[4], # w[3] is returned by readr via frictionless @@ -68,6 +73,12 @@ test_that("test warnings while reading files with parsing issues", { "`readr::problems()`." ) ) + problems_obs <- readr::problems(dp_issues$data$observations) + expect_equal(nrow(problems_obs), 2) + expect_equal(problems_obs$row, c(1,2)) + expect_equal(problems_obs$col, c(5,5)) + expect_equal(problems_obs$expected, rep("date like %Y-%m-%dT%H:%M:%S%z", 2)) + # warning on media expect_equal( w[6], # w[5] is returned by readr via frictionless @@ -77,6 +88,11 @@ test_that("test warnings while reading files with parsing issues", { "`readr::problems()`." ) ) + problems_media <- readr::problems(dp_issues$data$media) + expect_equal(nrow(problems_media), 1) + expect_equal(problems_media$row, 2) + expect_equal(problems_media$col, 5) + expect_equal(problems_media$expected, "date like %Y-%m-%dT%H:%M:%S%z") }) test_that("media is checked properly", { From d79224fd87f9e722425b4e6feb9d40a3c3b6df4a Mon Sep 17 00:00:00 2001 From: Damiano Oldoni Date: Fri, 29 Sep 2023 21:58:32 +0200 Subject: [PATCH 04/17] Assign to variable for checking problems --- tests/testthat/test-read_camtrap_dp.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index 1bd0eb3c..021274be 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -48,6 +48,7 @@ test_that("test warnings while reading files with parsing issues", { package = "camtraptor" ) w <- capture_warnings( + dp_issues <- camtraptor::read_camtrap_dp(file = camtrap_dp_file_with_issues) ) # warning on deployments expect_equal( From 0e2cb313611bf269a09cea09546ce532ca4ada08 Mon Sep 17 00:00:00 2001 From: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:24:00 +0200 Subject: [PATCH 05/17] Tests should be able to run in any order init object if you are going to use it, or alternatively create it outside of a test in the beginning of this file. --- tests/testthat/test-read_camtrap_dp.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index 021274be..5fa3727f 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -114,6 +114,12 @@ test_that("output is a list", { file = dp_path, media = FALSE )) + dp_v1_rc1_with_media <- suppressMessages( + read_camtrap_dp(path_to_json_v1rc1) + ) + dp_v1_rc1_without_media <- suppressMessages( + read_camtrap_dp(path_to_json_v1rc1, media = FALSE) + ) expect_true(is.list(dp_without_media)) expect_equal(class(dp_without_media), "list") expect_true(is.list(dp_v1_rc1_with_media)) From a4626db0b5e999689b69372f18938649c5e2b125 Mon Sep 17 00:00:00 2001 From: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:24:47 +0200 Subject: [PATCH 06/17] `expect_type` is easier to read than `expect_equal(class())` --- tests/testthat/test-read_camtrap_dp.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index 5fa3727f..f0884ee8 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -121,11 +121,11 @@ test_that("output is a list", { read_camtrap_dp(path_to_json_v1rc1, media = FALSE) ) expect_true(is.list(dp_without_media)) - expect_equal(class(dp_without_media), "list") + expect_type(dp_without_media, "list") expect_true(is.list(dp_v1_rc1_with_media)) - expect_equal(class(dp_v1_rc1_with_media), "list") + expect_type(dp_v1_rc1_with_media, "list") expect_true(is.list(dp_v1_rc1_without_media)) - expect_equal(class(dp_v1_rc1_without_media), "list") + expect_type(dp_v1_rc1_without_media, "list") }) test_that("output data slot is a list of length 3", { From fc8f00bfefccb1f91a7194bdda23d94f030ff0c5 Mon Sep 17 00:00:00 2001 From: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:31:17 +0200 Subject: [PATCH 07/17] init object in test so tests can run in any order --- tests/testthat/test-read_camtrap_dp.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index f0884ee8..4e9d7770 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -136,6 +136,9 @@ test_that("output data slot is a list of length 3", { file = dp_path, media = FALSE )) + dp_v1_rc1_without_media <- suppressMessages( + read_camtrap_dp(path_to_json_v1rc1, media = FALSE) + ) expect_true("data" %in% names(dp_without_media)) expect_equal(length(dp_without_media$data), 3) expect_true("data" %in% names(dp_v1_rc1_with_media)) From 464c08e525b014eecaf74392fe6dffc524ede3d0 Mon Sep 17 00:00:00 2001 From: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:32:12 +0200 Subject: [PATCH 08/17] `expect_length()` is easier to read than `expect_equal(length())` --- tests/testthat/test-read_camtrap_dp.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index 4e9d7770..e7e0d688 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -140,11 +140,11 @@ test_that("output data slot is a list of length 3", { read_camtrap_dp(path_to_json_v1rc1, media = FALSE) ) expect_true("data" %in% names(dp_without_media)) - expect_equal(length(dp_without_media$data), 3) + expect_length(dp_without_media$data, 3) expect_true("data" %in% names(dp_v1_rc1_with_media)) - expect_equal(length(dp_v1_rc1_with_media$data), 3) + expect_length(dp_v1_rc1_with_media$data, 3) expect_true("data" %in% names(dp_v1_rc1_without_media)) - expect_equal(length(dp_v1_rc1_without_media$data), 3) + expect_length(dp_v1_rc1_without_media$data, 3) }) test_that("media arg influences only slot media", { From f5ac2fc189e834a13598a3c4454a1c126dd21401 Mon Sep 17 00:00:00 2001 From: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:35:12 +0200 Subject: [PATCH 09/17] init object if used, so tests can run in any order --- tests/testthat/test-read_camtrap_dp.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index e7e0d688..8378f64f 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -405,6 +405,9 @@ test_that( file = dp_path, media = FALSE )) + dp_v1_rc1_without_media <- suppressMessages( + read_camtrap_dp(path_to_json_v1rc1, media = FALSE) + ) cols_deployments_dp_v1_rc1 <- dp_v1_rc1_without_media$data$deployments %>% names() cols_deployments_dp_v0_1_6 <- dp_without_media$data$deployments %>% From fbc890b40854f6ab7f75bd29fd988f11c5ed3fb8 Mon Sep 17 00:00:00 2001 From: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:35:27 +0200 Subject: [PATCH 10/17] increase test strictness, remove tolerance --- tests/testthat/test-read_camtrap_dp.R | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index 8378f64f..fe1307b9 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -51,7 +51,7 @@ test_that("test warnings while reading files with parsing issues", { dp_issues <- camtraptor::read_camtrap_dp(file = camtrap_dp_file_with_issues) ) # warning on deployments - expect_equal( + expect_identical( w[2], # w[1] is returned by readr via frictionless paste0( "One or more parsing issues occurred while reading `deployments`. ", @@ -60,13 +60,13 @@ test_that("test warnings while reading files with parsing issues", { ) ) problems_deploys <- readr::problems(dp_issues$data$deployments) - expect_equal(nrow(problems_deploys), 2) - expect_equal(problems_deploys$row, c(1,2)) - expect_equal(problems_deploys$col, c(7,7)) - expect_equal(problems_deploys$expected, rep("date like %Y-%m-%dT%H:%M:%S%z", 2)) + expect_identical(nrow(problems_deploys), 2L) + expect_identical(problems_deploys$row, c(1L,2L)) + expect_identical(problems_deploys$col, c(7L,7L)) + expect_identical(problems_deploys$expected, rep("date like %Y-%m-%dT%H:%M:%S%z", 2)) # warning on observations - expect_equal( + expect_identical( w[4], # w[3] is returned by readr via frictionless paste0( "One or more parsing issues occurred while reading `observations`. ", @@ -75,13 +75,13 @@ test_that("test warnings while reading files with parsing issues", { ) ) problems_obs <- readr::problems(dp_issues$data$observations) - expect_equal(nrow(problems_obs), 2) - expect_equal(problems_obs$row, c(1,2)) - expect_equal(problems_obs$col, c(5,5)) - expect_equal(problems_obs$expected, rep("date like %Y-%m-%dT%H:%M:%S%z", 2)) + expect_identical(nrow(problems_obs), 2L) + expect_identical(problems_obs$row, c(1L,2L)) + expect_identical(problems_obs$col, c(5L,5L)) + expect_identical(problems_obs$expected, rep("date like %Y-%m-%dT%H:%M:%S%z", 2)) # warning on media - expect_equal( + expect_identical( w[6], # w[5] is returned by readr via frictionless paste0( "One or more parsing issues occurred while reading `media`. ", @@ -90,10 +90,10 @@ test_that("test warnings while reading files with parsing issues", { ) ) problems_media <- readr::problems(dp_issues$data$media) - expect_equal(nrow(problems_media), 1) - expect_equal(problems_media$row, 2) - expect_equal(problems_media$col, 5) - expect_equal(problems_media$expected, "date like %Y-%m-%dT%H:%M:%S%z") + expect_identical(nrow(problems_media), 1L) + expect_identical(problems_media$row, 2L) + expect_identical(problems_media$col, 5L) + expect_identical(problems_media$expected, "date like %Y-%m-%dT%H:%M:%S%z") }) test_that("media is checked properly", { @@ -360,7 +360,7 @@ test_that( "read deployments v1.0-rc1: baitUse is a factor, not a boolean", { expect_s3_class(dp_v1_rc1_with_media$data$deployments$baitUse, "factor") baitUse_levels <- c("none", "scent", "food", "visual", "acoustic", "other") - expect_equal( + expect_identical( levels(dp_v1_rc1_with_media$data$deployments$baitUse), baitUse_levels ) # boolean NA becomes a factor NA @@ -412,7 +412,7 @@ test_that( names() cols_deployments_dp_v0_1_6 <- dp_without_media$data$deployments %>% names() - expect_equal(cols_deployments_dp_v0_1_6, cols_deployments_dp_v1_rc1) + expect_identical(cols_deployments_dp_v0_1_6, cols_deployments_dp_v1_rc1) } ) @@ -602,6 +602,6 @@ test_that( names() cols_media_dp_v0_1_6 <- dp_with_media$data$media %>% names() - expect_equal(cols_media_dp_v1_rc1, cols_media_dp_v0_1_6) + expect_identical(cols_media_dp_v1_rc1, cols_media_dp_v0_1_6) } ) From 57146c33d252bc94b66a7922b957f8e74d55685f Mon Sep 17 00:00:00 2001 From: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:39:41 +0200 Subject: [PATCH 11/17] move object creation needed for tests to start of file, remove inits from individual tests --- tests/testthat/test-read_camtrap_dp.R | 33 ++++++++++----------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index fe1307b9..c6160f07 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -1,3 +1,12 @@ +## read camera trap data package from v1.0-rc1 +path_to_json_v1rc1 <- "https://raw.githubusercontent.com/tdwg/camtrap-dp/1.0-rc.1/example/datapackage.json" +dp_v1_rc1_with_media <- suppressMessages( + read_camtrap_dp(path_to_json_v1rc1) +) +dp_v1_rc1_without_media <- suppressMessages( + read_camtrap_dp(path_to_json_v1rc1, media = FALSE) +) + test_that("file argument is checked properly", { expect_error(read_camtrap_dp("aaa")) expect_error(read_camtrap_dp(1)) @@ -31,15 +40,6 @@ test_that("only DP versions 1.0-rc.1 and dp 0.1.6 are supported", { ) }) -## read camera trap data package from v1.0-rc1 -path_to_json_v1rc1 <- "https://raw.githubusercontent.com/tdwg/camtrap-dp/1.0-rc.1/example/datapackage.json" -dp_v1_rc1_with_media <- suppressMessages( - read_camtrap_dp(path_to_json_v1rc1) -) -dp_v1_rc1_without_media <- suppressMessages( - read_camtrap_dp(path_to_json_v1rc1, media = FALSE) -) - test_that("test warnings while reading files with parsing issues", { local_edition(2) camtrap_dp_file_with_issues <- system.file( @@ -114,12 +114,7 @@ test_that("output is a list", { file = dp_path, media = FALSE )) - dp_v1_rc1_with_media <- suppressMessages( - read_camtrap_dp(path_to_json_v1rc1) - ) - dp_v1_rc1_without_media <- suppressMessages( - read_camtrap_dp(path_to_json_v1rc1, media = FALSE) - ) + expect_true(is.list(dp_without_media)) expect_type(dp_without_media, "list") expect_true(is.list(dp_v1_rc1_with_media)) @@ -136,9 +131,7 @@ test_that("output data slot is a list of length 3", { file = dp_path, media = FALSE )) - dp_v1_rc1_without_media <- suppressMessages( - read_camtrap_dp(path_to_json_v1rc1, media = FALSE) - ) + expect_true("data" %in% names(dp_without_media)) expect_length(dp_without_media$data, 3) expect_true("data" %in% names(dp_v1_rc1_with_media)) @@ -405,9 +398,7 @@ test_that( file = dp_path, media = FALSE )) - dp_v1_rc1_without_media <- suppressMessages( - read_camtrap_dp(path_to_json_v1rc1, media = FALSE) - ) + cols_deployments_dp_v1_rc1 <- dp_v1_rc1_without_media$data$deployments %>% names() cols_deployments_dp_v0_1_6 <- dp_without_media$data$deployments %>% From 1b749cd1ba692b9860640ddb611f4124a32f9fc2 Mon Sep 17 00:00:00 2001 From: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:50:37 +0200 Subject: [PATCH 12/17] use glue::glue to collapse instead of writeLines, so we can suppress this message in tests --- R/zzz.R | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/R/zzz.R b/R/zzz.R index cb886e00..fa012d91 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -462,12 +462,11 @@ convert_to_0.1.6 <- function(package, from = "1.0-rc.1", media = TRUE){ # notify about conversion message( - writeLines( - c( + glue::glue( "The dataset uses Camtrap DP version 1.0-rc.1, it has been converted to 0.1.6.", - "See https://inbo.github.io/camtraptor/#camtrap-dp for details." + "See https://inbo.github.io/camtraptor/#camtrap-dp for details.", + .seq = "\n" ) - ) ) # convert metadata package <- convert_metadata_to_0.1.6(package, from) From 49272246acd506bc259f038174c60b819d8237fb Mon Sep 17 00:00:00 2001 From: Damiano Oldoni Date: Wed, 8 Nov 2023 15:26:55 +0100 Subject: [PATCH 13/17] Remove windows-latest with R3.6.3 --- .github/workflows/R-CMD-check.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 38221a8e..ff1dc0c6 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -29,7 +29,6 @@ jobs: - {os: ubuntu-latest, r: 'release'} - {os: ubuntu-latest, r: 'oldrel-1'} - {os: ubuntu-latest, r: '3.6.3'} - - {os: windows-latest, r: '3.6.0'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} From 161339c6e4c7b718c3ab7f351f0d15d05f465090 Mon Sep 17 00:00:00 2001 From: Damiano Oldoni Date: Thu, 9 Nov 2023 16:32:04 +0100 Subject: [PATCH 14/17] Add camtraptor:: in what arg in lifecycle This should avoid returning an error while running covr as found by @PietrH. Co-Authored-By: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> --- R/read_camtrap_dp.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/read_camtrap_dp.R b/R/read_camtrap_dp.R index 4d6b2384..2337fa45 100644 --- a/R/read_camtrap_dp.R +++ b/R/read_camtrap_dp.R @@ -58,7 +58,7 @@ read_camtrap_dp <- function(file = NULL, if (lifecycle::is_present(path) | (!is.null(file) && dir.exists(file))) { lifecycle::deprecate_warn( when = "0.6.0", - what = "read_camtrap_dp(path)", + what = "camtraptor::read_camtrap_dp(path)", details = warning_detail ) } From 6860d5e43b1cc91b7e4b454f475847d9ba96ae64 Mon Sep 17 00:00:00 2001 From: Damiano Oldoni Date: Thu, 9 Nov 2023 16:35:34 +0100 Subject: [PATCH 15/17] Use captured_warnings instead of w Co-Authored-By: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> --- tests/testthat/test-read_camtrap_dp.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index de2ed3e3..aee3e39f 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -49,12 +49,12 @@ test_that("test warnings while reading files with parsing issues", { "datapackage_for_parsing_issues.json", package = "camtraptor" ) - w <- capture_warnings( + captured_warnings <- capture_warnings( dp_issues <- camtraptor::read_camtrap_dp(file = camtrap_dp_file_with_issues) ) # warning on deployments expect_identical( - w[2], # w[1] is returned by readr via frictionless + captured_warnings[2], # captured_warnings[1] is returned by readr via frictionless paste0( "One or more parsing issues occurred while reading `deployments`. ", "Check `?read_camtrap_dp()` for examples on how to use ", From e9e94e7193623c6ec7aad106aeecc4ac14eab34d Mon Sep 17 00:00:00 2001 From: Damiano Oldoni Date: Thu, 9 Nov 2023 16:46:39 +0100 Subject: [PATCH 16/17] Replace w with captured_warnings where forgotten Co-Authored-By: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> --- tests/testthat/test-read_camtrap_dp.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index aee3e39f..1816392d 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -70,7 +70,7 @@ test_that("test warnings while reading files with parsing issues", { # warning on observations expect_identical( - w[4], # w[3] is returned by readr via frictionless + captured_warnings[4], # captured_warnings[3] is returned by readr via frictionless paste0( "One or more parsing issues occurred while reading `observations`. ", "Check `?read_camtrap_dp()` for examples on how to use ", @@ -85,7 +85,7 @@ test_that("test warnings while reading files with parsing issues", { # warning on media expect_identical( - w[6], # w[5] is returned by readr via frictionless + captured_warnings[6], # captured_warnings[5] is returned by readr via frictionless paste0( "One or more parsing issues occurred while reading `media`. ", "Check `?read_camtrap_dp()` for examples on how to use ", From 36960137729a1b1f9e6f14a973abe9583a887818 Mon Sep 17 00:00:00 2001 From: Damiano Oldoni Date: Thu, 9 Nov 2023 16:46:54 +0100 Subject: [PATCH 17/17] Add check about number of warnings Co-Authored-By: Pieter Huybrechts <48065851+PietrH@users.noreply.github.com> --- tests/testthat/test-read_camtrap_dp.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/testthat/test-read_camtrap_dp.R b/tests/testthat/test-read_camtrap_dp.R index 1816392d..7b6d9da9 100644 --- a/tests/testthat/test-read_camtrap_dp.R +++ b/tests/testthat/test-read_camtrap_dp.R @@ -52,6 +52,10 @@ test_that("test warnings while reading files with parsing issues", { captured_warnings <- capture_warnings( dp_issues <- camtraptor::read_camtrap_dp(file = camtrap_dp_file_with_issues) ) + + # check number of warnings + expect_length(captured_warnings, 6) + # warning on deployments expect_identical( captured_warnings[2], # captured_warnings[1] is returned by readr via frictionless