Skip to content

Commit

Permalink
some real server testing
Browse files Browse the repository at this point in the history
  • Loading branch information
d-callan committed Dec 12, 2023
1 parent 735a613 commit 20970bd
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions tests/testthat/test-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,82 +13,82 @@ test_that("reactives and outputs update", {
correlationFilter = 0,
pValueFilter = 0.05)

data1$matrix <- corGraph::mpg_cty_hwy
data2$matrix <- corGraph::mpg_year_cyl
session$flushReact()

# trying to make sure we rendered some stuff
#output$pValueHistogram
#output$correlationHistogram
#output$correlationMatrix
#output$correlationNetwork
#output$bipartiteNetwork
output$pValueHistogram
output$correlationHistogram
output$correlationMatrix
output$correlationNetwork
output$bipartiteNetwork

# checking reactiveValues have values
expect_equal(upload_state$file1, 'uploaded')
expect_equal(upload_state$file2, 'uploaded')
#expect_equal(is.null(data1$matrix), FALSE)
#expect_equal(is.null(data2$matrix), FALSE)
#expect_equal(is.null(correlationMatrix$corr_matrix), FALSE)
#expect_equal(is.null(pValuesMatrix$p_values), FALSE)
expect_equal(is.null(data1$matrix), FALSE)
expect_equal(is.null(data2$matrix), FALSE)
expect_equal(is.null(correlationMatrix$corr_matrix), FALSE)
expect_equal(is.null(pValuesMatrix$p_values), FALSE)

# checking edgeList
#expect_equal(class(edgeList()$value), "numeric")
#expect_equal(class(edgeList()$p_value), "numeric")
#expect_equal(class(edgeList()$source), "character")
#expect_equal(class(edgeList()$target), "character")
#expect_equal(nrow(edgeList()) > 0, TRUE)
#expect_equal(all(edgeList()$source %in% colnames(data1$matrix)), TRUE)
#expect_equal(all(edgeList()$target %in% colnames(data2$matrix)), TRUE)
#expect_equal(any(edgeList()$target %in% colnames(data2$matrix)), FALSE)
#expect_equal(any(edgeList()$source %in% colnames(data1$matrix)), FALSE)
expect_equal(class(edgeList()$value), "numeric")
expect_equal(class(edgeList()$p_value), "numeric")
expect_equal(class(edgeList()$source), "character")
expect_equal(class(edgeList()$target), "factor")
expect_equal(nrow(edgeList()) > 0, TRUE)
expect_equal(all(edgeList()$source %in% colnames(data1$matrix)), TRUE)
expect_equal(all(edgeList()$target %in% colnames(data2$matrix)), TRUE)
expect_equal(any(edgeList()$target %in% colnames(data1$matrix)), FALSE)
expect_equal(any(edgeList()$source %in% colnames(data2$matrix)), FALSE)

# checking filteredEdgeList did work
#expect_equal(nrow(filteredEdgeList()) < nrow(edgeList()), TRUE)

# checking bipartiteNetwork
#expect_equal(class(bipartiteNetworkOutput()$data), "list")
#expect_equal(class(bipartiteNetworkOutput()$column1NodeIds), "character")
#expect_equal(class(bipartiteNetworkOutput()$column2NodeIds), "character")
expect_equal(nrow(filteredEdgeList()) < nrow(edgeList()), TRUE)

# reset data and check
#session$click("resetData")
#expect_equal(upload_state$file1, "reset")
#expect_equal(upload_state$file2, "reset")
#expect_equal(is.null(data1$matrix), TRUE)
#expect_equal(is.null(data2$matrix), TRUE)
#expect_equal(is.null(correlationMatrix$corr_matrix), TRUE)
#expect_equal(is.null(pValuesMatrix$p_values), TRUE)
#expect_equal(is.null(edgeList()), TRUE)
session$setInputs(resetData = TRUE,
correlationMethod = "spearman",
correlationFilter = 0,
pValueFilter = 0.05)
session$flushReact()
expect_equal(upload_state$file1, "reset")
expect_equal(upload_state$file2, "reset")
expect_equal(is.null(data1$matrix), TRUE)
expect_equal(is.null(data2$matrix), TRUE)
expect_equal(is.null(correlationMatrix$corr_matrix), TRUE)
expect_equal(is.null(pValuesMatrix$p_values), TRUE)
expect_error(edgeList())

# upload single file this time
#session$setInputs(fileUpload = "inst/extdata/mpg-all-continuous.tsv",
# fileUpload2 = NULL,
# correlationMethod = "spearman",
# correlationFilter = 0,
# pValueFilter = 0.05)
session$setInputs(fileUpload = "inst/extdata/mpg-all-continuous.tsv",
fileUpload2 = NULL,
correlationMethod = "spearman",
correlationFilter = 0,
pValueFilter = 0.05)

session$setInputs(resetData = TRUE)
data1$matrix <- mpg_all_cont
session$flushReact()

#expect_equal(upload_state$file1, 'uploaded')
#expect_equal(upload_state$file2, NULL)
#expect_equal(is.null(data1$matrix), FALSE)
#expect_equal(is.null(data2$matrix), TRUE)
#expect_equal(is.null(correlationMatrix$corr_matrix), FALSE)
#expect_equal(is.null(pValuesMatrix$p_values), FALSE)
expect_equal(is.null(data1$matrix), FALSE)
expect_equal(is.null(data2$matrix), TRUE)
expect_equal(is.null(correlationMatrix$corr_matrix), FALSE)
expect_equal(is.null(pValuesMatrix$p_values), FALSE)

# checking edgeList
#expect_equal(class(edgeList()$value), "numeric")
#expect_equal(class(edgeList()$p_value), "numeric")
#expect_equal(class(edgeList()$source), "character")
#expect_equal(class(edgeList()$target), "character")
#expect_equal(nrow(edgeList()) > 0, TRUE)
#expect_equal(all(edgeList()$source %in% colnames(data1$matrix)), TRUE)
#expect_equal(all(edgeList()$target %in% colnames(data2$matrix)), TRUE)
#expect_equal(any(edgeList()$target %in% colnames(data2$matrix)), FALSE)
#expect_equal(any(edgeList()$source %in% colnames(data1$matrix)), FALSE)
expect_equal(class(edgeList()$value), "numeric")
expect_equal(class(edgeList()$p_value), "numeric")
expect_equal(class(edgeList()$source), "factor")
expect_equal(class(edgeList()$target), "factor")
expect_equal(nrow(edgeList()) > 0, TRUE)
expect_equal(any(edgeList()$source %in% edgeList()$target), TRUE)

# checking filteredEdgeList did work
#expect_equal(nrow(filteredEdgeList()) < nrow(edgeList()), TRUE)
expect_equal(nrow(filteredEdgeList()) < nrow(edgeList()), TRUE)

# checking unipartiteNetwork
#expect_equal(class(unipartiteNetworkOutput()$data), "list")
#expect_equal(class(unipartiteNetworkOutput()$column1NodeIds), "character")
#expect_equal(class(unipartiteNetworkOutput()$column2NodeIds), "character")
# check unipartiteNetwork
output$correlationNetwork

})
})

0 comments on commit 20970bd

Please sign in to comment.