Skip to content

Commit

Permalink
improved handling of down API
Browse files Browse the repository at this point in the history
  • Loading branch information
equitable-equations committed Apr 9, 2024
1 parent c1a6e5d commit 17629d3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion man/download_assessment.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion tests/testthat/test-transect_glance.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,25 @@ test_that("transect_glance works", {
expect_equal(names(test_normal)[9], "fqa_db_region")
expect_equal(names(test_normal)[13], "custom_fqa_db_name")
expect_equal(typeof(test_normal$total_mean_c), "double")
} else {
# for when server doesn't respond
expect_message(download_transect(4492))
}

if (nrow(suppressMessages(download_transect(7025))) != 0) {
test_custom <- download_transect(7025) |>
transect_glance() # custom database
expect_equal(ncol(test_custom), 54)
expect_equal(nrow(test_custom), 1)
expect_equal(names(test_custom)[9], "fqa_db_region")
expect_equal(names(test_custom)[13], "custom_fqa_db_name")
expect_equal(typeof(test_custom$total_mean_c), "double")
} else {
# for when server doesn't respond
expect_message(download_transect(7025))
}

if (nrow(suppressMessages(download_transect(6444))) != 0) {
test_omernik <- download_transect(6444) |>
transect_glance() # includes omernik classification
expect_equal(ncol(test_omernik), 54)
Expand All @@ -39,7 +49,7 @@ test_that("transect_glance works", {
expect_equal(typeof(test_omernik$total_mean_c), "double")
} else {
# for when server doesn't respond
expect_message(download_transect(4492))
expect_message(download_transect(6444))
}

})
13 changes: 12 additions & 1 deletion tests/testthat/test-transect_phys.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,31 @@ test_that("transect_phys works", {
expect_equal(ncol(test), 6)
expect_equal(typeof(test[[2]]), "double")
expect_equal(names(test)[2], "frequency")
} else {
# for when API is down
expect_message(download_transect(4492))
}

if (nrow(suppressMessages(download_transect(7025))) != 0) {
test_raw <- download_transect(7025) # custom database
test <- transect_phys(test_raw)
expect_equal(ncol(test), 6)
expect_equal(typeof(test[[2]]), "double")
expect_equal(names(test)[2], "frequency")
} else {
# for when API is down
expect_message(download_transect(7025))
}

if (nrow(suppressMessages(download_transect(6444))) != 0) {
test_raw <- download_transect(6444) # includes omernik
test <- transect_phys(test_raw)
expect_equal(ncol(test), 6)
expect_equal(typeof(test[[2]]), "double")
expect_equal(names(test)[2], "frequency")
} else {
expect_message(download_transect(4492))
# for when API is down
expect_message(download_transect(6444))
}

})

0 comments on commit 17629d3

Please sign in to comment.