Skip to content

Commit

Permalink
Add gender data to ProjectData comparison tests
Browse files Browse the repository at this point in the history
- Add gender data to ProjectData comparison tests in test-data.R
- Rename gender files from 'gender' to 'gender.list'

Signed-off-by: Mirabdulla Yusifli <s8miyusi@stud.uni-saarland.de>
  • Loading branch information
Mirabdulla Yusifli authored and Mirabdulla Yusifli committed Dec 9, 2021
1 parent 92518f6 commit 867a712
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
14 changes: 14 additions & 0 deletions tests/test-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ test_that("Compare two ProjectData objects on empty data", {
## initialize a ProjectData object with the ProjectConf and clone it into another one
proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY_EMPTY, ARTIFACT)
proj.conf$update.value("pasta", TRUE)
proj.conf$update.value("gender", TRUE)
proj.data.one = ProjectData$new(project.conf = proj.conf)
proj.data.two = proj.data.one$clone(deep = TRUE)

Expand Down Expand Up @@ -74,6 +75,11 @@ test_that("Compare two ProjectData objects on empty data", {
proj.data.one$get.authors()
expect_true(proj.data.one$equals(proj.data.two), "Two identical ProjectData objects (authors).")

proj.data.two$get.gender()
expect_true(proj.data.one$equals(proj.data.two), "Two identical ProjectData objects (gender).")
proj.data.one$get.gender()
expect_true(proj.data.one$equals(proj.data.two), "Two identical ProjectData objects (gender).")

proj.data.one$set.project.conf.entry("synchronicity", TRUE)
proj.data.one$set.project.conf.entry("synchronicity.time.window", 5)
proj.data.one$get.synchronicity()
Expand All @@ -96,6 +102,7 @@ test_that("Compare two ProjectData objects on non-empty data", {
## initialize a ProjectData object with the ProjectConf and clone it into another one
proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, ARTIFACT)
proj.conf$update.value("pasta", TRUE)
proj.conf$update.value("gender", TRUE)

proj.data.one = ProjectData$new(project.conf = proj.conf)
proj.data.two = proj.data.one$clone(deep = TRUE)
Expand Down Expand Up @@ -145,6 +152,13 @@ test_that("Compare two ProjectData objects on non-empty data", {
proj.data.two$get.issues()
expect_true(proj.data.one$equals(proj.data.two), "Two identical ProjectData objects (issues.filtered).")

## test 'equals' on gender
proj.data.two$get.gender()
expect_false(proj.data.one$equals(proj.data.two), "Two non-identical ProjectData objects (gender).")

proj.data.one$get.gender()
expect_true(proj.data.one$equals(proj.data.two), "Two identical ProjectData objects (gender).")

## test 'equals' on authors
proj.data.two$get.authors()
expect_false(proj.data.one$equals(proj.data.two), "Two non-identical ProjectData objects (authors).")
Expand Down
6 changes: 4 additions & 2 deletions tests/test-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,12 @@ test_that("Read and parse the gender data.", {

## read the actual data
gender.data.read = read.gender(proj.conf$get.value("datapath.gender"))

rownames(gender.data.read) = NULL

## build the expected data.frame
gender.data.expected = data.frame(author.name = c("Thomas", "Olaf", "Karl", "Max", "udo", "Björn", "georg", "Hans", "Fritz fritz@example.org"),
gender = c("male", "female", "male", "male", "female", "male", "male", "male", NA))
gender.data.expected = data.frame(author.name = c("Björn", "Fritz fritz@example.org", "georg", "Hans", "Karl", "Max", "Olaf", "Thomas", "udo"),
gender = c("male", "", "male", "male", "male", "male", "female", "male", "female"))

## check the results
expect_identical(gender.data.read, gender.data.expected, info = "Gender data.")
Expand Down
Binary file removed tests/testthat-problems.rds
Binary file not shown.
11 changes: 5 additions & 6 deletions util-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -1296,8 +1296,7 @@ ProjectData = R6::R6Class("ProjectData",
if (private$project.conf$get.value("gender")) {

## if data are not read already, read them
if (empty(private$gender)) {

if (!self$is.data.source.cached("gender")) {
## read gender data from disk
gender.data = read.gender(self$get.data.path.gender())
self$set.gender(gender.data)
Expand All @@ -1323,8 +1322,6 @@ ProjectData = R6::R6Class("ProjectData",

author.name.contained = private$gender[["author.name"]] %in% private$authors[["author.name"]]
private$gender = private$gender[author.name.contained, ]
View(author.name.contained)
View(private$gender)
}
},

Expand Down Expand Up @@ -1516,7 +1513,9 @@ ProjectData = R6::R6Class("ProjectData",
private$authors = data
## add gender data if wanted
if (private$project.conf$get.value("gender")) {
if (empty(private$gender)) {

## if data are not read already, read them
if (!self$is.data.source.cached("gender")) {
## get data (no assignment because we just want to trigger anything gender-related)
self$get.gender()
} else {
Expand Down Expand Up @@ -1750,7 +1749,7 @@ ProjectData = R6::R6Class("ProjectData",

## define the data sources
unfiltered.data.sources = c("commits.unfiltered", "mails.unfiltered", "issues.unfiltered")
additional.data.sources = c("authors", "commit.messages", "synchronicity", "pasta")
additional.data.sources = c("authors", "commit.messages", "synchronicity", "pasta","gender")
main.data.sources = c("issues", "commits", "mails")

## set the right data sources to look for according to the argument
Expand Down

0 comments on commit 867a712

Please sign in to comment.