-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for issue/mail count methods for issue #188
Tests for PRs are missing since there is no test data including PRs yet Signed-off-by: Johannes Hostert <[email protected]>
- Loading branch information
1 parent
25bc006
commit d996e28
Showing
5 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
## Copyright 2018-2019 by Thomas Bock <[email protected]> | ||
## Copyright 2018-2019 by Klara Schlüter <[email protected]> | ||
## Copyright 2018-2019 by Jakob Kronawitter <[email protected]> | ||
## Copyright 2021 by Johannes Hostert <[email protected]> | ||
## All Rights Reserved. | ||
|
||
|
||
|
@@ -70,6 +71,32 @@ get.network.covariates.test.networks = function(network.type = c("author", "arti | |
return(list("networks" = input.data.networks, "project.data" = project.data)) | ||
} | ||
|
||
|
||
#' Load test data and generate test networks, but including issues | ||
#' | ||
#' @return Tuple containing project data and list of networks | ||
get.network.covariates.test.networks.with.issues = function(network.type = c("author", "artifact")) { | ||
|
||
network.type.function = paste("get", match.arg(network.type), "network", sep = ".") | ||
|
||
## configuration and data objects | ||
proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT) | ||
proj.conf$update.value("commits.filter.base.artifact", FALSE) | ||
proj.conf$update.value("commits.filter.untracked.files", TRUE) | ||
proj.conf$update.value("issues.only.comments", FALSE) | ||
net.conf = NetworkConf$new() | ||
net.conf$update.values(list(author.relation = "cochange", simplify = FALSE)) | ||
|
||
## retrieve project data and network builder | ||
project.data = ProjectData$new(proj.conf) | ||
|
||
## split data | ||
input.data = split.data.time.based(project.data, bins = mybins) | ||
input.data.networks = lapply(input.data, function(d) NetworkBuilder$new(d, net.conf)[[network.type.function]]()) | ||
|
||
return(list("networks" = input.data.networks, "project.data" = project.data)) | ||
} | ||
|
||
#' Helper for the first activitity tests: Gets the first activity per person and data source for possible | ||
#' aggregation levels as a nested list. | ||
#' | ||
|
@@ -486,6 +513,143 @@ test_that("Test add.vertex.attribute.commit.count.committer.or.author", { | |
}) | ||
}) | ||
|
||
#' Test the add.vertex.attribute.mail.count method | ||
test_that("Test add.vertex.attribute.mail.count", { | ||
## Test setup | ||
networks.and.data = get.network.covariates.test.networks() | ||
|
||
expected.attributes = list( | ||
range = network.covariates.test.build.expected(c(1L), c(0L), c(1L, 0L, 0L)), | ||
cumulative = network.covariates.test.build.expected(c(1L), c(1L), c(2L, 0L, 1L)), | ||
all.ranges = network.covariates.test.build.expected(c(1L), c(2L), c(2L, 0L, 1L)), | ||
project.cumulative = network.covariates.test.build.expected(c(3L), c(1L), c(2L, 0L, 1L)), | ||
project.all.ranges = network.covariates.test.build.expected(c(3L), c(2L), c(2L, 0L, 1L)), | ||
complete = network.covariates.test.build.expected(c(3L), c(2L), c(2L, 0L, 1L)) | ||
) | ||
|
||
## Test | ||
|
||
lapply(AGGREGATION.LEVELS, function(level) { | ||
networks.with.attr = add.vertex.attribute.mail.count( | ||
networks.and.data[["networks"]], networks.and.data[["project.data"]], aggregation.level = level | ||
) | ||
|
||
actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "mail.count") | ||
|
||
expect_identical(expected.attributes[[level]], actual.attributes) | ||
}) | ||
}) | ||
|
||
#' Test the add.vertex.attribute.mail.count method | ||
test_that("Test add.vertex.attribute.mail.thread.count", { | ||
## Test setup | ||
networks.and.data = get.network.covariates.test.networks() | ||
|
||
expected.attributes = list( | ||
range = network.covariates.test.build.expected(c(1L), c(0L), c(1L, 0L, 0L)), | ||
cumulative = network.covariates.test.build.expected(c(1L), c(1L), c(2L, 0L, 1L)), | ||
all.ranges = network.covariates.test.build.expected(c(1L), c(2L), c(2L, 0L, 1L)), | ||
project.cumulative = network.covariates.test.build.expected(c(3L), c(1L), c(2L, 0L, 1L)), | ||
project.all.ranges = network.covariates.test.build.expected(c(3L), c(2L), c(2L, 0L, 1L)), | ||
complete = network.covariates.test.build.expected(c(3L), c(2L), c(2L, 0L, 1L)) | ||
) | ||
|
||
## Test | ||
|
||
lapply(AGGREGATION.LEVELS, function(level) { | ||
networks.with.attr = add.vertex.attribute.mail.thread.count( | ||
networks.and.data[["networks"]], networks.and.data[["project.data"]], aggregation.level = level | ||
) | ||
|
||
actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "mail.thread.count") | ||
|
||
expect_identical(expected.attributes[[level]], actual.attributes) | ||
}) | ||
}) | ||
|
||
#' Test the add.vertex.attribute.mail.count method | ||
test_that("Test add.vertex.attribute.issue.count", { | ||
## Test setup | ||
networks.and.data = get.network.covariates.test.networks.with.issues() | ||
|
||
expected.attributes = list( | ||
range = network.covariates.test.build.expected(c(0L), c(0L), c(1L, 1L, 0L)), | ||
cumulative = network.covariates.test.build.expected(c(0L), c(1L), c(1L, 1L, 1L)), | ||
all.ranges = network.covariates.test.build.expected(c(2L), c(1L), c(1L, 1L, 1L)), | ||
project.cumulative = network.covariates.test.build.expected(c(1L), c(2L), c(2L, 1L, 2L)), | ||
project.all.ranges = network.covariates.test.build.expected(c(3L), c(2L), c(2L, 1L, 2L)), | ||
complete = network.covariates.test.build.expected(c(3L), c(3L), c(3L, 1L, 3L)) | ||
) | ||
|
||
## Test | ||
|
||
lapply(AGGREGATION.LEVELS, function(level) { | ||
networks.with.attr = add.vertex.attribute.issue.count( | ||
networks.and.data[["networks"]], networks.and.data[["project.data"]], aggregation.level = level | ||
) | ||
|
||
actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "issues.count") | ||
|
||
expect_identical(expected.attributes[[level]], actual.attributes) | ||
}) | ||
}) | ||
|
||
|
||
#' Test the add.vertex.attribute.mail.count method | ||
test_that("Test add.vertex.attribute.issue.count.by.commenting", { | ||
## Test setup | ||
networks.and.data = get.network.covariates.test.networks.with.issues() | ||
|
||
expected.attributes = list( | ||
range = network.covariates.test.build.expected(c(0L), c(0L), c(0L, 0L, 0L)), | ||
cumulative = network.covariates.test.build.expected(c(0L), c(0L), c(0L, 1L, 1L)), | ||
all.ranges = network.covariates.test.build.expected(c(1L), c(0L), c(0L, 1L, 1L)), | ||
project.cumulative = network.covariates.test.build.expected(c(1L), c(1L), c(1L, 1L, 2L)), | ||
project.all.ranges = network.covariates.test.build.expected(c(2L), c(1L), c(1L, 1L, 2L)), | ||
complete = network.covariates.test.build.expected(c(3L), c(1L), c(1L, 1L, 2L)) | ||
) | ||
|
||
## Test | ||
|
||
lapply(AGGREGATION.LEVELS, function(level) { | ||
networks.with.attr = add.vertex.attribute.issue.count.by.commenting( | ||
networks.and.data[["networks"]], networks.and.data[["project.data"]], aggregation.level = level | ||
) | ||
|
||
actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "issues.count.by.commenting") | ||
|
||
expect_identical(expected.attributes[[level]], actual.attributes) | ||
}) | ||
}) | ||
|
||
#' Test the add.vertex.attribute.mail.count method | ||
test_that("Test add.vertex.attribute.issue.comment.count", { | ||
## Test setup | ||
networks.and.data = get.network.covariates.test.networks.with.issues() | ||
|
||
expected.attributes = list( | ||
range = network.covariates.test.build.expected(c(0L), c(0L), c(0L, 0L, 0L)), | ||
cumulative = network.covariates.test.build.expected(c(0L), c(0L), c(0L, 1L, 1L)), | ||
all.ranges = network.covariates.test.build.expected(c(2L), c(0L), c(0L, 1L, 1L)), | ||
project.cumulative = network.covariates.test.build.expected(c(6L), c(4L), c(4L, 1L, 2L)), | ||
project.all.ranges = network.covariates.test.build.expected(c(8L), c(4L), c(4L, 1L, 2L)), | ||
complete = network.covariates.test.build.expected(c(9L), c(4L), c(4L, 1L, 2L)) | ||
) | ||
|
||
## Test | ||
|
||
lapply(AGGREGATION.LEVELS, function(level) { | ||
networks.with.attr = add.vertex.attribute.issue.comment.count( | ||
networks.and.data[["networks"]], networks.and.data[["project.data"]], aggregation.level = level | ||
) | ||
|
||
actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "issue.comment.count") | ||
logging::logdebug(level) | ||
expect_identical(expected.attributes[[level]], actual.attributes) | ||
}) | ||
}) | ||
|
||
|
||
#' Test the add.vertex.attribute.author.email method | ||
test_that("Test add.vertex.attribute.author.email", { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
## Copyright 2018 by Klara Schlüter <[email protected]> | ||
## Copyright 2019 by Thomas Bock <[email protected]> | ||
## Copyright 2019 by Jakob Kronawitter <[email protected]> | ||
## Copyright 2021 by Johannes Hostert <[email protected]> | ||
## All Rights Reserved. | ||
## | ||
## This file is derived from following Codeface script: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
## Copyright 2018-2019 by Jakob Kronawitter <[email protected]> | ||
## Copyright 2019-2020 by Anselm Fehnker <[email protected]> | ||
## Copyright 2020-2021 by Niklas Schneider <[email protected]> | ||
## Copyright 2021 by Johannes Hostert <[email protected]> | ||
## All Rights Reserved. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
## Copyright 2018-2019 by Klara Schlüter <[email protected]> | ||
## Copyright 2018 by Jakob Kronawitter <[email protected]> | ||
## Copyright 2020 by Christian Hechtl <[email protected]> | ||
## Copyright 2021 by Johannes Hostert <[email protected]> | ||
## All Rights Reserved. | ||
|
||
## / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
## Copyright 2017-2018 by Thomas Bock <[email protected]> | ||
## Copyright 2020 by Thomas Bock <[email protected]> | ||
## Copyright 2021 by Niklas Schneider <[email protected]> | ||
## Copyright 2021 by Johannes Hostert <[email protected]> | ||
## All Rights Reserved. | ||
|
||
|
||
|