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 4eb15de commit fdc5712
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 0 additions & 2 deletions tests/testthat/test-download_assessment_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ test_that("download_assessment_internal works", {
expect_equal(nrow(null_output), 0)
expect_equal(memoise::has_cache(download_assessment_internal)(-40000), TRUE)

skip_if_offline()

test_a <- suppressMessages(download_assessment_internal(25002))
expect_equal(class(test_a), c("tbl_df",
"tbl",
Expand Down
6 changes: 4 additions & 2 deletions tests/testthat/test-download_assessment_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ test_that("download_assessment_list works", {

skip_if_offline()

if(length(suppressMessages(index_fqa_assessments(1))) != 0){
two_assessments <- suppressMessages(download_assessment_list(1,
id == 8 | id == 12))

if(length(two_assessments) != 0) {
expect_message(download_assessment_list(1, id == "hi"), "No matches found. Empty list returned.")
two_assessments <- download_assessment_list(1, id == 8 | id == 12)
expect_equal(class(two_assessments), "list")
expect_equal(length(two_assessments), 2)
expect_equal(class(two_assessments[[1]]), c("tbl_df",
Expand Down
4 changes: 1 addition & 3 deletions tests/testthat/test-download_database_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ test_that("download_database_internal works", {
test_db <- suppressMessages(download_database_internal(1))

if (nrow(test_db) != 0) {
# when server responds
expect_equal(ncol(test_db), 9)
expect_equal(test_db$V1[1], "Chicago Region")
expect_equal(class(test_db), c("tbl_df",
"tbl",
"data.frame"))
} else {
# for when server doesn't respond
expect_message(download_database_internal(1))
}
})
4 changes: 1 addition & 3 deletions tests/testthat/test-is_inventory.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ test_that("is_inventory works", {
edison <- suppressMessages(download_assessment(25002))

if (nrow(edison) != 0) {
# when server responds
expect_true(is_inventory(assessment_inventory(edison)))
} else {
# for when server doesn't respond
expect_false(is_inventory(assessment_inventory(edison)))
}

})

0 comments on commit fdc5712

Please sign in to comment.