Skip to content

Commit

Permalink
improve unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
noriakis committed Aug 24, 2023
1 parent b15c935 commit 45ee6b9
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export(rawMap)
export(rawValue)
export(return_line_compounds)
import(BiocFileCache)
import(Cairo)
import(ggplot2)
import(ggraph)
import(igraph)
Expand Down
1 change: 1 addition & 0 deletions R/ggkegg.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#' g + geom_node_rect()
#' @import ggraph
#' @import ggplot2
#' @import Cairo
#' @importFrom tidygraph as_tbl_graph
#' @importFrom igraph induced.subgraph delete_vertex_attr
#' @importFrom methods new
Expand Down
15 changes: 12 additions & 3 deletions tests/testthat/test-highlight.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
test_that("Highlight functions without errors", {
test_that("Highlight node functions without errors", {
graph <- create_test_pathway()
expect_error( graph |> mutate(hl=highlight_set_nodes(c("hsa:51428"))), NA)
expect_error( graph |> activate("edges") |>
expect_error(graph |> mutate(hl=highlight_set_nodes(c("hsa:51428"))), NA)
})
test_that("Highlight edge functions without errors", {
graph <- create_test_pathway()
expect_error(graph |> activate("edges") |>
mutate(hl=highlight_set_edges(c("degradation"),
name="subtype_name")), NA)
})
test_that("Highlight module functions without errors", {
graph <- create_test_pathway()
mo <- create_test_module()
expect_error(graph <- graph |> highlight_module(mo), NA)
})



8 changes: 7 additions & 1 deletion tests/testthat/test-module.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
test_that("Module parsing without errors", {
test_that("Module parsing to text and network without errors", {
expect_error( create_test_module(), NA)
mod <- create_test_module()

## Text parsing
expect_error( module_text(mod), NA)
expect_error( module_text(mod) |> plot_module_text(), NA)
mod <- module("M00004")
expect_error( module_text(mod), NA)
expect_error( module_text(mod) |> plot_module_text(), NA)

## Network parsing
expect_error( obtain_sequential_module_definition(mod) |>
plot_module_blocks(), NA)
})
11 changes: 10 additions & 1 deletion tests/testthat/test-pathway.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
test_that("Pathway parsing without errors", {
test_that("Generate test pathway without errors", {
expect_error( create_test_pathway(), NA)
})
test_that("Pathway downloading without errors", {
expect_error( pathway("hsa04110"), NA)
})
test_that("process_line without errors", {
expect_error( create_test_pathway(line=TRUE) |> process_line(), NA)
})
test_that("process_reaction without errors", {
expect_error( create_test_pathway(line=TRUE) |> process_reaction(), NA)
})
11 changes: 11 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@ test_that("Do utils without errors", {
name="graphics_name")),
NA)
})

test_that("edge_matrix without errors", {
graph <- create_test_pathway()
num_df <- data.frame(row.names=c("6737","51428"),
"sample1"=c(1.1,1.2),
"sample2"=c(1.1,1.2),
check.names=FALSE)
expect_error(graph <- graph |> edge_matrix(num_df, gene_type="ENTREZID"),
NA)
})

0 comments on commit 45ee6b9

Please sign in to comment.