Skip to content

Commit

Permalink
improved stability when server is down
Browse files Browse the repository at this point in the history
  • Loading branch information
equitable-equations committed Mar 31, 2024
1 parent 8155a3d commit 62412f2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions tests/testthat/test-assessment_list_glance.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test_that("assessment_list_glance works", {
expect_equal(ncol(test_df), 52)

if (length(test_list) != 0){
# when server responds
expect_lt(nrow(test_df)-1, length(test_list))
expect_equal(typeof(test_df$total_mean_c), "double")
}
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-database_inventory.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ test_that("database_inventory works", {
expect_equal(names(test_man)[5], "c")
expect_equal(typeof(test_man$c), "double")

skip_if_offline()

test_raw <- suppressMessages(download_assessment(25002))

if (nrow(test_raw != 0)) {
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-download_assessment.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ test_that("download_assessment works", {
expect_equal(nrow(null_output), 0)
expect_equal(memoise::has_cache(download_assessment_internal)(-40000), FALSE)

skip_if_offline()

test_assessment <- suppressMessages(download_assessment(25002))
expect_equal(ncol(test_assessment), 9)

if (nrow(test_assessment) !=0){
expect_equal(memoise::has_cache(download_assessment_internal)(25002), TRUE)
expect_equal(nrow(test_a), 140)
expect_equal(test_a$V1[1], "Edison dune and swale")
}
})

3 changes: 3 additions & 0 deletions tests/testthat/test-download_assessment_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ test_that("download_assessment_internal works", {
expect_equal(nrow(test_a), 140)
expect_equal(ncol(test_a), 9)
expect_equal(test_a$V1[1], "Edison dune and swale")
} else {
expect_message(download_assessment_internal(25002))
}

})
4 changes: 1 addition & 3 deletions tests/testthat/test-download_assessment_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ test_that("download_assessment_list works", {

expect_equal(class(suppressMessages(download_assessment_list(-2))), "list")

skip_if_offline()

two_assessments <- suppressMessages(download_assessment_list(1,
id == 8 | id == 12))

if(length(two_assessments) != 0) {
# when server responds
expect_message(download_assessment_list(1, id == "hi"), "No matches found. Empty list returned.")
expect_equal(class(two_assessments), "list")
expect_equal(length(two_assessments), 2)
Expand Down

0 comments on commit 62412f2

Please sign in to comment.