Skip to content

Commit

Permalink
Test different sets of PIs per receiver project. Closes #20.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhpob committed Jun 15, 2024
1 parent ea26c56 commit 950c3a7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
7 changes: 4 additions & 3 deletions R/project_contacts.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ project_contacts <- function(extract, type = c("receiver", "tag")) {
POC = strsplit(contact_poc, " \\(|\\)(, )?")
)]
} else {
pis <- unique(extract, by = c("trackercode"))
pis <- unique(extract, by = c("trackercode", "tag_contact_poc", "tag_contact_pi"))
pis[, ":="(
PI = strsplit(tag_contact_pi, " \\(|\\)(, )?"),
POC = strsplit(tag_contact_poc, " \\(|\\)(, )?")
Expand Down Expand Up @@ -99,9 +99,10 @@ project_contacts <- function(extract, type = c("receiver", "tag")) {
),
by = "trackercode"
]
pis <- merge(pis[, -c("PI", "POC", "PI_emails", "POC_emails")],
pis <- merge(
pis[, -c("PI", "POC", "PI_emails", "POC_emails")],
pi_key,
on = "trackercode"
by = "trackercode"
)
pis <- unique(pis, by = "trackercode")
}
Expand Down
29 changes: 27 additions & 2 deletions tests/testthat/test-project_contacts.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,41 @@ test_that("Multiple sets of tag PIs per project are summarized", {

expect_match(
pi_table[pi_table$project_name == "HFX",]$PI,
"Matthew Apostle, Mary Mother, Dave Hebert, Fred Whoriskey"
"Matthew Apostle, Mary Mother, Dave Hebert, Fred Whoriskey",
fixed = TRUE
)

expect_match(
pi_table[pi_table$project_name == "HFX",]$PI_emails,
"matt@bible,mary@bible,david.hebert@dfo-mpo.gc.ca,fwhoriskey@dal.ca"
"matt@bible,mary@bible,david.hebert@dfo-mpo.gc.ca,fwhoriskey@dal.ca",
fixed = TRUE
)

})

test_that("Multiple sets of receiver PIs per project are summarized", {
qual_multiple_pis <- qualified
qual_multiple_pis[qual_multiple_pis$trackercode == 'TAG',][1, 'tag_contact_pi'] <-
c("Matthew Apostle (matt@bible), Mary Mother (mary@bible)")

pi_table <- project_contacts(qual_multiple_pis, "receiver")

expect_false(
any(
duplicated(pi_table$project_name)
)
)

expect_match(
pi_table[pi_table$project_name == "TAG",]$PI,
"Matthew Apostle, Mary Mother, Barbara Block",
fixed = TRUE
)

expect_match(
pi_table[pi_table$project_name == "TAG",]$PI_emails,
"matt@bible,mary@bible,bblock@stanford.edu",
fixed = TRUE
)

})

0 comments on commit 950c3a7

Please sign in to comment.