Skip to content

Commit

Permalink
Add tests for deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdesmet committed Oct 18, 2021
1 parent 11d99bc commit 13ef7a4
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 6 deletions.
12 changes: 6 additions & 6 deletions R/etn-deprecated.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ NULL
#' @export
get_deployments <- function(connection = con, network_project_code = NULL, ...) {
.Deprecated("get_acoustic_deployments")
get_acoustic_deployments(acoustic_project_code = network_project_code, ...)
get_acoustic_deployments(connection, acoustic_project_code = network_project_code, ...)
}

#' @rdname etn-deprecated
#' @export
get_detections <- function(connection = con, tag_id = NULL, network_project_code = NULL, ...) {
.Deprecated("get_acoustic_detections")
get_acoustic_detections(acoustic_tag_id = tag_id, acoustic_project_code = network_project_code, ...)
get_acoustic_detections(connection, acoustic_tag_id = tag_id, acoustic_project_code = network_project_code, ...)
}

#' @rdname etn-deprecated
Expand All @@ -27,16 +27,16 @@ get_projects <- function(connection = con, project_type, application_type) {
.Deprecated("get_animal_projects, get_acoustic_projects or get_cpod_projects")
if (!missing("project_type")) {
if (project_type == "network") {
get_acoustic_projects()
get_acoustic_projects(connection)
} else {
get_animal_projects()
get_animal_projects(connection)
}
} else if (!missing("application_type")) {
if (application_type == "cpod") {
get_cpod_projects()
get_cpod_projects(connection)
}
} else {
get_animal_projects()
get_animal_projects(connection)
}
}

Expand Down
64 changes: 64 additions & 0 deletions tests/testthat/test-etn-deprecated.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
con <- connect_to_etn()

test_that("get_deployments() redirects to correct function", {
expect_warning(get_deployments(con), "is deprecated")
suppressWarnings(expect_equal(
get_deployments(con, network_project_code = "demer"),
get_acoustic_deployments(con, acoustic_project_code = "demer")
))
})

test_that("get_detections() redirects to correct function", {
expect_warning(get_detections(con, limit = TRUE), "is deprecated")
suppressWarnings(expect_equal(
get_detections(
con,
tag_id = "A69-1601-16130",
network_project_code = "demer",
limit = TRUE
),
get_acoustic_detections(
con,
acoustic_tag_id = "A69-1601-16130",
acoustic_project_code = "demer",
limit = TRUE
)
))
})

test_that("get_projects() redirects to correct function", {
expect_warning(get_projects(con), "is deprecated")
suppressWarnings(expect_equal(
get_projects(con), get_animal_projects(con)
))
suppressWarnings(expect_equal(
get_projects(con, project_type = "animal"), get_animal_projects(con)
))
suppressWarnings(expect_equal(
get_projects(con, project_type = "network"), get_acoustic_projects(con)
))
suppressWarnings(expect_equal(
get_projects(con, application_type = "cpod"), get_cpod_projects(con)
))
})

test_that("get_receivers() redirects to correct function", {
expect_warning(get_receivers(con), "is deprecated")
suppressWarnings(expect_equal(
get_receivers(con), get_acoustic_receivers(con)
))
})

test_that("list_network_project_codes() redirects to correct function", {
expect_warning(list_network_project_codes(con), "is deprecated")
suppressWarnings(expect_equal(
list_network_project_codes(con), list_acoustic_project_codes(con)
))
})

test_that("list_tag_ids() redirects to correct function", {
expect_warning(list_tag_ids(con), "is deprecated")
suppressWarnings(expect_equal(
list_tag_ids(con), list_acoustic_tag_ids(con)
))
})

0 comments on commit 13ef7a4

Please sign in to comment.