Am 29/10/15 um 11:57 schrieb Mitchell Joblin:
- Check the dispatch.all function works correctly and produces the
correct network
Signed-off-by: Mitchell Joblin <mitchell.joblin.ext@xxxxxxxxxxx>
---
codeface/R/ml/test_analysis.r | 42 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/codeface/R/ml/test_analysis.r b/codeface/R/ml/test_analysis.r
index 02333d3..be0b480 100644
--- a/codeface/R/ml/test_analysis.r
+++ b/codeface/R/ml/test_analysis.r
@@ -1,8 +1,11 @@
library(testthat)
+source("../db.r", chdir=T)
source("analysis.r")
-conf <- list(listname="gmane.comp.emulators.qemu")
+conf <- connect.db("../../../codeface_testing.conf")
+conf$listname <- "gmane.comp.emulators.qemu"
+
path <- "test_data"
res.dir <- "test_data"
@@ -21,10 +24,45 @@ test.check.corpus.precon <- function() {
return(all(check.eq))
}
+test.global.analysis <- function () {
+ project.name <- "test_mail"
+ analysis.method <- "mail"
+ conf$pid <- gen.clear.project.id.con(conf$con, project.name,is unique(unlist(edgelist[,c(1,2)])) guaranteed to return a continuous
analysis.method)
+
+ ## Run analysis
+ dispatch.all(conf, path, res.dir)
+
+ ## Query for edgelist
+ start.date <- "2000-01-01"
+ end.date <- "2020-01-01"
+ edgelist <- query.mail.edgelist(conf$con, conf$pid, start.date, end.date)
+
+ ## Get author id to name mapping
+ id.to.name <- sapply(unique(unlist(edgelist[,c(1,2)])),
+ function(id) query.person.name(conf$con, id))
+ edgelist[,c(1,2)] <- sapply(edgelist[,c(1,2)], function(id) id.to.name[id])
+
+ ## Generate graph from database data
+ g.db <- graph.data.frame(edgelist)
+
+ ## Generate target graph
+ edgelist.target <- data.frame(from=c("chatty kathy", "nasty nate"),
+ to=c("bossy bill", "sneaky sam"),
+ weight=1)
+ g.target <- graph.data.frame(edgelist.target)
+
+ ## Test for edge agreement
+ res <- all(E(g.target) == E(g.db))
+}
+
test_that("Forest generation functions correctly", {
expect_true(test.genforest())
})
test_that("Corpus precondiction checks works", {
expect_true(test.check.corpus.precon())
- })
\ No newline at end of file
+ })
+
+test_that("Global analysis returns correct network", {
+ expect_true(test.global.analysis())
+ })