tests/testthat/test_provParse.R

library(EnviR)

## Loading test data
test.data <- system.file("tests", "ddg.json", package = "EnviR")
prov.parse(test.data)

context("Environment access function")
envi.df <- get.environment()
expect_match(class(envi.df), "data.frame")
expect_match(typeof(envi.df$value), "character")

context("Procedure nodes access function")
proc.df <- get.proc.nodes()
expect_match(class(proc.df), "data.frame")
expect_match(typeof(proc.df$name), "character")
expect_match(typeof(proc.df$type), "character")
expect_match(typeof(proc.df$elapsedTime), "double")
expect_match(typeof(proc.df$scriptNum), "integer")
expect_match(typeof(proc.df$startLine), "integer")
expect_match(typeof(proc.df$startCol), "integer")
expect_match(typeof(proc.df$endLine), "integer")
expect_match(typeof(proc.df$endCol), "integer")

context("Data nodes access function")
data.df <- get.data.nodes()
expect_match(class(data.df), "data.frame")
expect_match(typeof(data.df$name), "character")
expect_match(typeof(data.df$value), "character")
expect_match(typeof(data.df$valType), "character")
expect_match(typeof(data.df$type), "character")
expect_match(typeof(data.df$scope), "character")
expect_match(typeof(data.df$fromEnv), "logical")
expect_match(typeof(data.df$MD5hash), "character")
expect_match(typeof(data.df$timestamp), "character")
expect_match(typeof(data.df$location), "character")

context("Function nodes access function")
func.df <- get.func.nodes()
expect_match(class(func.df), "data.frame")
expect_match(typeof(func.df$name), "character")

context("Procedure-to-procedure edges access function")
proc.proc.df <- get.proc.proc()
expect_match(class(proc.proc.df), "data.frame")
expect_match(typeof(proc.proc.df$informant), "character")
expect_match(typeof(proc.proc.df$informed), "character")

context("Data-to-procedure edges access function")
data.proc.df <- get.data.proc()
expect_match(class(data.proc.df), "data.frame")
expect_match(typeof(data.proc.df$entity), "character")
expect_match(typeof(data.proc.df$activity), "character")

context("Procedure-to-data edges access function")
proc.data.df <- get.proc.data()
expect_match(class(proc.data.df), "data.frame")
expect_match(typeof(proc.data.df$entity), "character")
expect_match(typeof(proc.data.df$activity), "character")

context("Function-to-procedure edges access function")
func.proc.df <- get.func.proc()
expect_match(class(func.proc.df), "data.frame")
expect_match(typeof(func.proc.df$entity), "character")
expect_match(typeof(func.proc.df$activity), "character")

context("Function-library group nodes access function")
func.lib.df <- get.func.lib()
expect_match(class(func.lib.df), "data.frame")
expect_match(typeof(func.lib.df$collection), "character")
expect_match(typeof(func.lib.df$entity), "character")

context("Library nodes access function")
libs.df <- get.libs()
expect_match(class(libs.df), "data.frame")
expect_match(typeof(libs.df$name), "character")
expect_match(typeof(libs.df$version), "character")

context("Scripts access function")
scripts.df <- get.scripts()
expect_match(class(scripts.df), "data.frame")
if(nrow(scripts.df) > 0){
  expect_match(typeof(scripts.df$scripts), "character")
  expect_match(typeof(scripts.df$timestamps), "character")
}
blernermhc/provParseR documentation built on May 31, 2019, 6:14 p.m.