Skip to content

Commit

Permalink
Change tests to match new function names
Browse files Browse the repository at this point in the history
Also use patrick to test for directedness

Signed-off-by: Leo Sendelbach <[email protected]>
  • Loading branch information
Leo-Send committed Apr 17, 2024
1 parent 1335965 commit 8ce1f07
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
5 changes: 3 additions & 2 deletions tests/test-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,10 @@ test_that("Compare two ProjectData Objects with commit.interactions", {
"0a1a5c523d835459c42f33e863623138555e2526",
"1143db502761379c2bfcecc2007fc34282e7ee61",
"0a1a5c523d835459c42f33e863623138555e2526")
commit.interactions.data.expected[["func"]] = c("GLOBAL", "test2", "GLOBAL", "test2")
commit.interactions.data.expected[["func"]] = c("GLOBAL", "test2.c::test2", "GLOBAL", "test2.c::test2")
commit.interactions.data.expected[["file"]] = c("GLOBAL", "test2.c", "GLOBAL", "test2.c")
commit.interactions.data.expected[["base.func"]] = c("test2", "test2", "test_function", "test2")
commit.interactions.data.expected[["base.func"]] = c("test2.c::test2", "test2.c::test2",
"test3.c::test_function", "test2.c::test2")
commit.interactions.data.expected[["base.file"]] = c("test2.c", "test2.c", "test3.c", "test2.c")

expect_equal(proj.data.two$get.commit.interactions(), commit.interactions.data.expected)
Expand Down
36 changes: 23 additions & 13 deletions tests/test-networks-artifact.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ patrick::with_parameters_test_that("Network construction of an empty 'comments-o
"directed: TRUE" = list(test.directed = TRUE)
))

test_that("Network construction with commit-interactions as relation, artifact type 'file'", {
patrick::with_parameters_test_that("Network construction with commit-interactions as relation, artifact type 'file'", {
## configuration object for the datapath
proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, "file")
proj.conf$update.value("commit.interactions", TRUE)
Expand All @@ -222,7 +222,8 @@ test_that("Network construction with commit-interactions as relation, artifact t
proj.data = ProjectData$new(project.conf = proj.conf)

net.conf = NetworkConf$new()
net.conf$update.value("artifact.relation", "commit.interaction")
net.conf$update.values(updated.values = list(artifact.relation = "commit.interaction",
artifact.directed = test.directed))

network.builder = NetworkBuilder$new(project.data = proj.data, network.conf = net.conf)
network.built = network.builder$get.artifact.network()
Expand All @@ -235,7 +236,7 @@ test_that("Network construction with commit-interactions as relation, artifact t
edges = data.frame(
from = c("GLOBAL", "test2.c", "GLOBAL", "test2.c"),
to = c("test2.c", "test2.c", "test3.c", "test2.c"),
func = c("GLOBAL", "test2", "GLOBAL", "test2"),
func = c("GLOBAL", "test2.c::test2", "GLOBAL", "test2.c::test2"),
hash = c("0a1a5c523d835459c42f33e863623138555e2526",
"418d1dc4929ad1df251d2aeb833dd45757b04a6f",
"5a5ec9675e98187e1e92561e1888aa6f04faa338",
Expand All @@ -244,19 +245,23 @@ test_that("Network construction with commit-interactions as relation, artifact t
"0a1a5c523d835459c42f33e863623138555e2526",
"1143db502761379c2bfcecc2007fc34282e7ee61",
"0a1a5c523d835459c42f33e863623138555e2526"),
base.func = c("test2", "test2", "test_function", "test2"),
base.func = c("test2.c::test2", "test2.c::test2",
"test3.c::test_function", "test2.c::test2"),
base.author = c("Olaf", "Thomas", "Karl", "Thomas"),
interacting.author = c("Thomas", "Karl", "Olaf", "Thomas"),
weight = c(1, 1, 1, 1),
type = c(TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA),
relation = c("commit.interaction", "commit.interaction", "commit.interaction", "commit.interaction")
)
network = igraph::graph.data.frame(edges, directed = FALSE, vertices = vertices)
network = igraph::graph.data.frame(edges, directed = test.directed, vertices = vertices)

expect_true(igraph::identical_graphs(network.built, network))
})
}, patrick::cases(
"directed: FALSE" = list(test.directed = FALSE),
"directed: TRUE" = list(test.directed = TRUE)
))

test_that("Network construction with commit-interactions as relation, artifact type 'function'", {
patrick::with_parameters_test_that("Network construction with commit-interactions as relation, artifact type 'function'", {
## configuration object for the datapath
proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, "function")
proj.conf$update.value("commit.interactions", TRUE)
Expand All @@ -265,19 +270,21 @@ test_that("Network construction with commit-interactions as relation, artifact t
proj.data = ProjectData$new(project.conf = proj.conf)

net.conf = NetworkConf$new()
net.conf$update.value("artifact.relation", "commit.interaction")
net.conf$update.values(updated.values = list(artifact.relation = "commit.interaction",
artifact.directed = test.directed))

network.builder = NetworkBuilder$new(project.data = proj.data, network.conf = net.conf)
network.built = network.builder$get.artifact.network()
## build the expected network
vertices = data.frame(
name = c("test2", "test_function", "GLOBAL"),
name = c("test2.c::test2", "test3.c::test_function", "GLOBAL"),
kind = "Function",
type = TYPE.ARTIFACT
)
edges = data.frame(
from = c("GLOBAL", "test2", "GLOBAL", "test2"),
to = c("test2", "test2", "test_function", "test2"),
from = c("GLOBAL", "test2.c::test2", "GLOBAL", "test2.c::test2"),
to = c("test2.c::test2", "test2.c::test2",
"test3.c::test_function", "test2.c::test2"),
hash = c("0a1a5c523d835459c42f33e863623138555e2526",
"418d1dc4929ad1df251d2aeb833dd45757b04a6f",
"5a5ec9675e98187e1e92561e1888aa6f04faa338",
Expand All @@ -294,7 +301,10 @@ test_that("Network construction with commit-interactions as relation, artifact t
type = c(TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA),
relation = c("commit.interaction", "commit.interaction", "commit.interaction", "commit.interaction")
)
network = igraph::graph.data.frame(edges, directed = FALSE, vertices = vertices)
network = igraph::graph.data.frame(edges, directed = test.directed, vertices = vertices)

expect_true(igraph::identical_graphs(network.built, network))
})
}, patrick::cases(
"directed: FALSE" = list(test.directed = FALSE),
"directed: TRUE" = list(test.directed = TRUE)
))
17 changes: 11 additions & 6 deletions tests/test-networks-author.R
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ test_that("Network construction with only untracked files (no edges expected)",
expect_true(igraph::identical_graphs(network.built, network.expected))
})

test_that("Network construction with commit-interactions as relation", {
patrick::with_parameters_test_that("Network construction with commit-interactions as relation", {
## configuration object for the datapath
proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, "file")
proj.conf$update.value("commit.interactions", TRUE)
Expand All @@ -688,7 +688,8 @@ test_that("Network construction with commit-interactions as relation", {
proj.data = ProjectData$new(project.conf = proj.conf)

net.conf = NetworkConf$new()
net.conf$update.value("author.relation", "commit.interaction")
net.conf$update.values(updated.values = list(author.relation = "commit.interaction",
author.directed = test.directed))

network.builder = NetworkBuilder$new(project.data = proj.data, network.conf = net.conf)
network.built = network.builder$get.author.network()
Expand All @@ -702,7 +703,7 @@ test_that("Network construction with commit-interactions as relation", {
edges = data.frame(
from = c("Olaf", "Thomas", "Karl", "Thomas"),
to = c("Thomas", "Karl", "Olaf", "Thomas"),
func = c("GLOBAL", "test2", "GLOBAL", "test2"),
func = c("GLOBAL", "test2.c::test2", "GLOBAL", "test2.c::test2"),
hash = c("0a1a5c523d835459c42f33e863623138555e2526",
"418d1dc4929ad1df251d2aeb833dd45757b04a6f",
"5a5ec9675e98187e1e92561e1888aa6f04faa338",
Expand All @@ -712,13 +713,17 @@ test_that("Network construction with commit-interactions as relation", {
"0a1a5c523d835459c42f33e863623138555e2526",
"1143db502761379c2bfcecc2007fc34282e7ee61",
"0a1a5c523d835459c42f33e863623138555e2526"),
base.func = c("test2", "test2", "test_function", "test2"),
base.func = c("test2.c::test2", "test2.c::test2",
"test3.c::test_function", "test2.c::test2"),
base.file = c("test2.c", "test2.c", "test3.c", "test2.c"),
weight = c(1, 1, 1, 1),
type = c(TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA),
relation = c("commit.interaction", "commit.interaction", "commit.interaction", "commit.interaction")
)
network = igraph::graph.data.frame(edges, directed = FALSE, vertices = vertices)
network = igraph::graph.data.frame(edges, directed = test.directed, vertices = vertices)

expect_true(igraph::identical_graphs(network.built, network))
})
}, patrick::cases(
"directed: FALSE" = list(test.directed = FALSE),
"directed: TRUE" = list(test.directed = TRUE)
))
5 changes: 3 additions & 2 deletions tests/test-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,10 @@ test_that("Read the commit-interactions data.", {
"3a0ed78458b3976243db6829f63eba3eead26774",
"0a1a5c523d835459c42f33e863623138555e2526",
"0a1a5c523d835459c42f33e863623138555e2526")
commit.interactions.data.expected[["func"]] = c("GLOBAL", "GLOBAL", "test2", "test2")
commit.interactions.data.expected[["func"]] = c("GLOBAL", "GLOBAL", "test2.c::test2", "test2.c::test2")
commit.interactions.data.expected[["file"]] = c("GLOBAL", "GLOBAL", "test2.c", "test2.c")
commit.interactions.data.expected[["base.func"]] = c("test_function", "test2", "test2", "test2")
commit.interactions.data.expected[["base.func"]] = c("test3.c::test_function", "test2.c::test2",
"test2.c::test2", "test2.c::test2")
commit.interactions.data.expected[["base.file"]] = c("test3.c", "test2.c", "test2.c", "test2.c")
## check the results
expect_identical(commit.interactions.data.read, commit.interactions.data.expected,
Expand Down

0 comments on commit 8ce1f07

Please sign in to comment.