Skip to content

Commit

Permalink
Add test for author network
Browse files Browse the repository at this point in the history
Test easy construction of an author network with interaction as relation

Signed-off-by: Leo Sendelbach <[email protected]>
  • Loading branch information
Leo-Send committed Mar 6, 2024
1 parent 05ea1ce commit 99103f2
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/test-networks-author.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
## Copyright 2021 by Johannes Hostert <[email protected]>
## Copyright 2023-2024 by Maximilian Löffler <[email protected]>
## Copyright 2024 by Leo Sendelbach <[email protected]>

## All Rights Reserved.


Expand Down Expand Up @@ -677,3 +678,47 @@ test_that("Network construction with only untracked files (no edges expected)",
## test
expect_true(igraph::identical_graphs(network.built, network.expected))
})

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)
proj.conf$update.value("commits.filter.untracked.files", FALSE)
proj.conf$update.value("commits.filter.base.artifact", FALSE)
proj.data = ProjectData$new(project.conf = proj.conf)

net.conf = NetworkConf$new()
net.conf$update.value("author.relation", "interaction")

network.builder = NetworkBuilder$new(project.data = proj.data, network.conf = net.conf)
network.built = network.builder$get.author.network()

## build the expected nbetwork
vertices = data.frame(
name = c("Olaf", "Thomas", "Björn", "Karl"),
kind = TYPE.AUTHOR,
type = TYPE.AUTHOR
)
edges = data.frame(
from = c("Olaf", "Thomas", "Björn", "Thomas"),
to = c("Thomas", "Karl", "Olaf", "Thomas"),
func = c("test2.c", "test2.c", "test.c", "test2.c"),
hash = c("0a1a5c523d835459c42f33e863623138555e2526",
"418d1dc4929ad1df251d2aeb833dd45757b04a6f",
"5a5ec9675e98187e1e92561e1888aa6f04faa338",
"d01921773fae4bed8186b0aa411d6a2f7a6626e6"),
file = c("test2.c", "test2.c", "test.c", "test2.c"),
base.hash = c("3a0ed78458b3976243db6829f63eba3eead26774",
"0a1a5c523d835459c42f33e863623138555e2526",
"72c8dd25d3dd6d18f46e2b26a5f5b1e2e8dc28d0",
"0a1a5c523d835459c42f33e863623138555e2526"),
base.func = c("test2.c", "test2.c", "test.c", "test2.c"),
base.file = c("test2.c", "test2.c", "test.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("interaction", "interaction", "interaction", "interaction")
)
network = igraph::graph.data.frame(edges, directed = FALSE, vertices = vertices)

expect_true(igraph::identical_graphs(network.built, network))
})

0 comments on commit 99103f2

Please sign in to comment.