Skip to content

Commit

Permalink
New and improved issue handling, support for issue/pr/both counting i…
Browse files Browse the repository at this point in the history
…n all varieties one can imagine (and more)

Signed-off-by: Johannes Hostert <[email protected]>
  • Loading branch information
JoJoDeveloping committed Mar 23, 2021
1 parent 139f70b commit eb4f649
Show file tree
Hide file tree
Showing 5 changed files with 301 additions and 326 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@
6;"Distinguish directedness of networks and edge-construction algorithm";"[""issue"", ""bug"", ""enhancement""]";"open";"[]";"2016-07-12 14:30:13";"";"[]";"subscribed";"Björn";"[email protected]";"2016-12-07 15:30:02";"udo";"""[email protected]"""
6;"Distinguish directedness of networks and edge-construction algorithm";"[""issue"", ""bug"", ""enhancement""]";"open";"[]";"2016-07-12 14:30:13";"";"[]";"labeled";"Olaf";"[email protected]";"2017-05-23 12:31:34";"decided";""""""
6;"Distinguish directedness of networks and edge-construction algorithm";"[""issue"", ""bug"", ""enhancement""]";"open";"[]";"2016-07-12 14:30:13";"";"[]";"commented";"Björn";"[email protected]";"2017-05-23 12:32:39";"open";"[]"
"1";"Example pull request 1";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"created";"Thomas";"[email protected]";"2016-07-12 15:59:25";"open";"[]"
"1";"Example pull request 1";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"commented";"Thomas";"[email protected]";"2016-07-12 15:59:25";"open";"[]"
"1";"Example pull request 1";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"commented";"Olaf";"[email protected]";"2016-07-12 16:01:01";"open";"[]"
"1";"Example pull request 1";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"commented";"Björn";"[email protected]";"2016-07-12 16:06:01";"open";"[]"
"1";"Example pull request 1";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"state_updated";"Thomas";"[email protected]";"2016-07-12 15:59:59";"closed";"""open"""
"1";"Example pull request 1";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"state_updated";"Olaf";"[email protected]";"2016-07-14 13:37:00";"closed";"""open"""
"2";"Example pull request 2";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"created";"Björn";"[email protected]";"2016-07-12 14:59:25";"open";"[]"
"2";"Example pull request 2";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"commented";"Björn";"[email protected]";"2016-07-12 14:59:25";"open";"[]"
"2";"Example pull request 2";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"state_updated";"Björn";"[email protected]";"2016-07-12 15:00:01";"closed";"""open"""
"2";"Example pull request 2";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"state_updated";"Olaf";"[email protected]";"2016-07-12 16:04:59";"closed";"""open"""
"4";"Example pull request 4";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"created";"Olaf";"[email protected]";"2016-07-12 16:02:02";"open";"[]"
"4";"Example pull request 4";"[""pull request""]";"closed";"[]";"2013-05-13 02:46:44";"2013-09-05 14:48:10";"[]";"commented";"Olaf";"[email protected]";"2016-07-12 16:02:02";"open";"[]"
179 changes: 134 additions & 45 deletions tests/test-networks-covariates.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,10 @@ myranges = construct.ranges(mybins, sliding.window = FALSE)

#' Load test data and generate test networks
#'
#' @return Tuple containing project data and list of networks
get.network.covariates.test.networks = 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)
project.data$set.issues(NULL)

## 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))
}


#' Load test data and generate test networks, but including issues
#' @param issues Whether to retain issue data. If \code{FALSE}, issue data is deleted. [default: FALSE]
#'
#' @return Tuple containing project data and list of networks
get.network.covariates.test.networks.with.issues = function(network.type = c("author", "artifact")) {
get.network.covariates.test.networks = function(network.type = c("author", "artifact"), issues = FALSE) {

network.type.function = paste("get", match.arg(network.type), "network", sep = ".")

Expand All @@ -87,8 +62,11 @@ get.network.covariates.test.networks.with.issues = function(network.type = c("au
net.conf = NetworkConf$new()
net.conf$update.values(list(author.relation = "cochange", simplify = FALSE))

## retrieve project data and network builder
## retrieve project data
project.data = ProjectData$new(proj.conf)
if (!issues) {
project.data$set.issues(NULL)
}

## split data
input.data = split.data.time.based(project.data, bins = mybins)
Expand Down Expand Up @@ -570,9 +548,9 @@ test_that("Test add.vertex.attribute.mail.thread.count", {
#' 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()
networks.and.data = get.network.covariates.test.networks(issues=TRUE)

expected.attributes = list(
expected.attributes.issues.only = 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)),
Expand All @@ -581,26 +559,47 @@ test_that("Test add.vertex.attribute.issue.count", {
complete = network.covariates.test.build.expected(c(3L), c(3L), c(3L, 1L, 3L))
)

## Test
expected.attributes.prs.only = list(
range = network.covariates.test.build.expected(c(1L), c(3L), c(1L, 0L, 0L)),
cumulative = network.covariates.test.build.expected(c(1L), c(3L), c(3L, 0L, 1L)),
all.ranges = network.covariates.test.build.expected(c(2L), c(3L), c(3L, 0L, 1L)),
project.cumulative = network.covariates.test.build.expected(c(1L), c(3L), c(3L, 0L, 1L)),
project.all.ranges = network.covariates.test.build.expected(c(2L), c(3L), c(3L, 0L, 1L)),
complete = network.covariates.test.build.expected(c(2L), c(3L), c(3L, 0L, 1L))
)

## Test issues only

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
networks.and.data[["networks"]], networks.and.data[["project.data"]], aggregation.level = level, issue.type = "issues"
)

actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "issues.count")
actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "issue.count")

expect_identical(expected.attributes[[level]], actual.attributes)
expect_identical(expected.attributes.issues.only[[level]], actual.attributes)
})

# Test PRs only

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, issue.type = "pull.requests", name = "pull.request.count"
)

actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "pull.request.count")

expect_identical(expected.attributes.prs.only[[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()
networks.and.data = get.network.covariates.test.networks(issues = TRUE)

expected.attributes = list(
expected.attributes.issues.only = 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)),
Expand All @@ -609,25 +608,94 @@ test_that("Test add.vertex.attribute.issue.count.by.commenting", {
complete = network.covariates.test.build.expected(c(3L), c(1L), c(1L, 1L, 2L))
)

## Test
expected.attributes.prs.only = list(
range = network.covariates.test.build.expected(c(0L), c(2L), c(0L, 0L, 0L)),
cumulative = network.covariates.test.build.expected(c(0L), c(2L), 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(1L), c(2L), c(2L, 0L, 1L)),
project.all.ranges = network.covariates.test.build.expected(c(2L), c(2L), c(2L, 0L, 1L)),
complete = network.covariates.test.build.expected(c(2L), c(2L), c(2L, 0L, 1L))
)

## Test issues only

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
networks.and.data[["networks"]], networks.and.data[["project.data"]], aggregation.level = level, issue.type = "issues"
)

actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "issues.count.by.commenting")
actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "issue.count.by.commenting")

expect_identical(expected.attributes[[level]], actual.attributes)
expect_identical(expected.attributes.issues.only[[level]], actual.attributes)
})

# Test PRs only

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, issue.type = "pull.requests", name = "pull.request.count.by.commenting"
)

actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "pull.request.count.by.commenting")

expect_identical(expected.attributes.prs.only[[level]], actual.attributes)
})
})

#' Test the add.vertex.attribute.mail.count method
test_that("Test add.vertex.attribute.issue.creation.count", {
## Test setup
networks.and.data = get.network.covariates.test.networks(issues = TRUE)

expected.attributes.issues.only = 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, 0L)),
all.ranges = network.covariates.test.build.expected(c(1L), c(0L), c(0L, 1L, 0L)),
project.cumulative = network.covariates.test.build.expected(c(0L), c(0L), c(0L, 1L, 1L)),
project.all.ranges = network.covariates.test.build.expected(c(1L), c(0L), c(0L, 1L, 1L)),
complete = network.covariates.test.build.expected(c(1L), c(0L), c(0L, 1L, 1L))
)

expected.attributes.prs.only = list(
range = network.covariates.test.build.expected(c(0L), c(1L), c(0L, 0L, 0L)),
cumulative = network.covariates.test.build.expected(c(0L), c(1L), c(1L, 0L, 1L)),
all.ranges = network.covariates.test.build.expected(c(0L), c(1L), c(1L, 0L, 1L)),
project.cumulative = network.covariates.test.build.expected(c(1L), c(1L), c(1L, 0L, 1L)),
project.all.ranges = network.covariates.test.build.expected(c(1L), c(1L), c(1L, 0L, 1L)),
complete = network.covariates.test.build.expected(c(1L), c(1L), c(1L, 0L, 1L))
)

## Test issues only

lapply(AGGREGATION.LEVELS, function(level) {
networks.with.attr = add.vertex.attribute.issue.creation.count(
networks.and.data[["networks"]], networks.and.data[["project.data"]], aggregation.level = level, issue.type = "issues"
)

actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "issue.creation.count")

expect_identical(expected.attributes.issues.only[[level]], actual.attributes)
})

# Test PRs only

lapply(AGGREGATION.LEVELS, function(level) {
networks.with.attr = add.vertex.attribute.issue.creation.count(
networks.and.data[["networks"]], networks.and.data[["project.data"]], aggregation.level = level, issue.type = "pull.requests", name = "pull.request.creation.count"
)

actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "pull.request.creation.count")

expect_identical(expected.attributes.prs.only[[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()
networks.and.data = get.network.covariates.test.networks(issues = TRUE)

expected.attributes = list(
expected.attributes.issues.only = 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)),
Expand All @@ -636,16 +704,37 @@ test_that("Test add.vertex.attribute.issue.comment.count", {
complete = network.covariates.test.build.expected(c(9L), c(4L), c(4L, 1L, 2L))
)

## Test
expected.attributes.prs.only = list(
range = network.covariates.test.build.expected(c(0L), c(2L), c(0L, 0L, 0L)),
cumulative = network.covariates.test.build.expected(c(0L), c(2L), 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(1L), c(2L), c(2L, 0L, 1L)),
project.all.ranges = network.covariates.test.build.expected(c(2L), c(2L), c(2L, 0L, 1L)),
complete = network.covariates.test.build.expected(c(2L), c(2L), c(2L, 0L, 1L))
)

## Test issues only

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
networks.and.data[["networks"]], networks.and.data[["project.data"]], aggregation.level = level, issue.type = "issues"
)

actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "issue.comment.count")
logging::logdebug(level)
expect_identical(expected.attributes[[level]], actual.attributes)
expect_identical(expected.attributes.issues.only[[level]], actual.attributes)
})

# Test PRs only

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, issue.type = "pull.requests", name = "pull.request.comment.count"
)

actual.attributes = lapply(networks.with.attr, igraph::get.vertex.attribute, name = "pull.request.comment.count")

expect_identical(expected.attributes.prs.only[[level]], actual.attributes)
})
})

Expand Down
Loading

0 comments on commit eb4f649

Please sign in to comment.