From 030574b9d0f3435db4032d0e195a3d407fb7244b Mon Sep 17 00:00:00 2001 From: Leo Sendelbach Date: Tue, 9 Jan 2024 16:20:34 +0100 Subject: [PATCH] Add tests for get.author.names.from.data Signed-off by: Leo Sendelbach --- tests/test-util-networks-misc.R | 138 ++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/tests/test-util-networks-misc.R b/tests/test-util-networks-misc.R index 585fb2a4..4a8404c1 100644 --- a/tests/test-util-networks-misc.R +++ b/tests/test-util-networks-misc.R @@ -156,5 +156,143 @@ test_that("getting all authors of a list of networks, list length 2, not global" ## Assert expected = list(c("Dieter", "Heinz", "Klaus"), c("Detlef", "Dieter")) + expect_equal(expected, result) +}) + +test_that("getting all authors of a list of data ranges, list length 0", { + + ## Act + result = get.author.names.from.data(data.ranges = list()) + + ## Assert + expected = list(c()) + + expect_equal(expected, result) +}) + +test_that("getting all authors of a list of data ranges, list length 1", { + + ## Arrange + proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT) + proj.data.base = ProjectData$new(project.conf = proj.conf) + range.data = proj.data.base$get.data.cut.to.same.date("mails") + + ## Act + result = get.author.names.from.data(data.ranges = list(range.data)) + + ## Assert + expected = list(c("Björn", "Fritz fritz@example.org","georg", "Hans", + "Karl", "Olaf", "Thomas", "udo")) + + expect_equal(expected, result) +}) + +test_that("getting all authors of a list of data ranges, list length 1, not global", { + + ## Arrange + proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT) + proj.data.base = ProjectData$new(project.conf = proj.conf) + range.data = proj.data.base$get.data.cut.to.same.date("mails") + + ## Act + result = get.author.names.from.data(data.ranges = list(range.data), globally = FALSE) + + ## Assert + expected = list(c("Björn", "Fritz fritz@example.org","georg", "Hans", + "Karl", "Olaf", "Thomas", "udo")) + + expect_equal(expected, result) +}) + +test_that("getting all authors of a list of data ranges, list length 2", { + + ## Arrange + proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT) + proj.data.base = ProjectData$new(project.conf = proj.conf) + range.data.one = proj.data.base$get.data.cut.to.same.date("mails") + range.data.two = proj.data.base$get.data.cut.to.same.date("issues") + + ## Act + result = get.author.names.from.data(data.ranges = list(range.data.one, range.data.two)) + + ## Assert + expected = list(c("Björn", "Fritz fritz@example.org","georg", "Hans", + "Karl", "Max", "Olaf", "Thomas", "udo")) + + expect_equal(expected, result) +}) + +test_that("getting all authors of a list of data ranges, list length 2, not global", { + + ## Arrange + proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT) + proj.data.base = ProjectData$new(project.conf = proj.conf) + range.data.one = proj.data.base$get.data.cut.to.same.date("mails") + range.data.two = proj.data.base$get.data.cut.to.same.date("issues") + + ## Act + result = get.author.names.from.data(data.ranges = list(range.data.one, range.data.two), globally = FALSE) + + ## Assert + expected = list(c("Björn", "Fritz fritz@example.org","georg", "Hans", "Karl", "Olaf", + "Thomas", "udo"), c("Björn", "Karl", "Max", "Olaf", "Thomas")) + + expect_equal(expected, result) +}) + +test_that("getting all authors of a list of data ranges by data source 'mails', list length 2, not global", { + + ## Arrange + proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT) + proj.data.base = ProjectData$new(project.conf = proj.conf) + range.data.one = proj.data.base$get.data.cut.to.same.date("mails") + range.data.two = proj.data.base$get.data.cut.to.same.date("issues") + + ## Act + result = get.author.names.from.data(data.ranges = list(range.data.one, range.data.two), + data.sources = "mails", globally = FALSE) + + ## Assert + + expected = list(c("Björn", "Fritz fritz@example.org","georg", "Hans", "Olaf", + "Thomas", "udo"), c("Björn", "Olaf", "Thomas")) + + expect_equal(expected, result) +}) + +test_that("getting all authors of a list of data ranges by data source 'issues', list length 2, not global", { + + ## Arrange + proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT) + proj.data.base = ProjectData$new(project.conf = proj.conf) + range.data.one = proj.data.base$get.data.cut.to.same.date("mails") + range.data.two = proj.data.base$get.data.cut.to.same.date("issues") + + ## Act + result = get.author.names.from.data(data.ranges = list(range.data.one, range.data.two), + data.sources = "issues", globally = FALSE) + + ## Assert + expected = list(c("Björn", "Karl", "Olaf", "Thomas"), c("Björn","Karl", "Max", "Olaf", "Thomas")) + + expect_equal(expected, result) +}) + +test_that("getting all authors of a list of data ranges by data source 'commits', list length 2, not global", { + + ## Arrange + proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT) + proj.data.base = ProjectData$new(project.conf = proj.conf) + range.data.one = proj.data.base$get.data.cut.to.same.date("mails") + range.data.two = proj.data.base$get.data.cut.to.same.date("issues") + + ## Act + result = get.author.names.from.data(data.ranges = list(range.data.one, range.data.two), + data.sources = "commits", globally = FALSE) + + ## Assert + + expected = list(c("Björn", "Olaf"), c("Björn", "Olaf", "Thomas")) + expect_equal(expected, result) }) \ No newline at end of file