Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
redraven committed Aug 1, 2019
2 parents 99ba278 + 6610487 commit 2e584d8
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 124 deletions.
Empty file removed R/.Rapp.history
Empty file.
61 changes: 0 additions & 61 deletions tests/testthat/atest-smk-ds.merge.o.R

This file was deleted.

49 changes: 0 additions & 49 deletions tests/testthat/atest-smk-ds.reShape.o.R

This file was deleted.

5 changes: 4 additions & 1 deletion tests/testthat/test-arg-ds.Boole.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
source("connection_to_datasets/init_all_datasets.R")
source("connection_to_datasets/init_smk_datasets.R")

connect.smk.dataset.sim(list("LAB_TSC"))
connect.smk.dataset.sim(list("LAB_TSC", "LAB_TRIG"))

#
# Tests
Expand All @@ -27,6 +27,9 @@ connect.smk.dataset.sim(list("LAB_TSC"))
context("ds.Boole.o::arg::test errors")
test_that("Boole_erros", {
expect_error(ds.Boole.o(), "Please provide the name of the column or scalar that holds V1!", fixed=TRUE)
expect_error(ds.Boole.o(V1="D$LAB_TSC"), "Please provide the name of a column or scalar holding V2 or declare a scalar in character format: eg '3'", fixed=TRUE)
expect_error(ds.Boole.o(V1="D$LAB_TSC", V2="LAB_TRIG"), "Please provide a Boolean operator in character format: eg '==' or '>=' or '<' or '!='", fixed=TRUE)
expect_error(ds.Boole.o(V1="D$LAB_TSC", V2="LAB_TRIG", Boolean.operator="==", na.assign=2), "Error: na.assign must be a character string taking value 'NA', '0' or '1'- if <na.action> not specified default is 'NA'", fixed=TRUE)
})

#
Expand Down
16 changes: 14 additions & 2 deletions tests/testthat/test-arg-ds.asCharacter.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
# context("dsBetaTestClient::ds.asCharacter.o:args test")

source("connection_to_datasets/init_all_datasets.R")
source("connection_to_datasets/init_smk_datasets.R")
source("connection_to_datasets/init_discordant_datasets.R")

connect.smk.dataset.sim(list("LAB_TSC"))
connect.discordant.dataset.simple(list("A", "B", "C"))

#
# Tests
Expand All @@ -29,6 +29,18 @@ test_that("asCharacter_erros", {
expect_error(ds.asCharacter.o(), "Please provide the name of the input vector!", fixed=TRUE)
})

# context("ds.asCharacter.o::arg::discordant errors")
# test_that("asCharacter_discordant", {
# res <- ds.asCharacter.o("D$A")
#
# print("====")
# print(res)
# print("====")
#
# expect_length(res, )
# expect_equal(res, "")
# })

#
# Done
#
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-arg-ds.asFactor.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ connect.smk.dataset.sim(list("LAB_TSC"))
context("ds.asFactor.o::arg::test errors")
test_that("asFactor_erros", {
expect_error(ds.asFactor.o(), "Please provide the name of the variable that is to be converted to a factor e.g. 'varname'", fixed=TRUE)
expect_error(ds.asFactor.o(input.var.name=1), "Please provide the name of the variable that is to be converted to a factor in character format e.g. 'varname'", fixed=TRUE)
expect_error(ds.asFactor.o(input.var.name=NA), "Please provide the name of the variable that is to be converted to a factor in character format e.g. 'varname'", fixed=TRUE)
})

#
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-arg-ds.cbind.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ connect.smk.dataset.sim(list("LAB_TSC"))

context("ds.cbind.o::arg::test errors")
test_that("cbind_erros", {
ds.asList.o(x='D$LAB_TSC', newobj="as_list")

expect_error(ds.cbind.o(), "Please provide a vector of character strings holding the name of the input elements!", fixed=TRUE)
expect_error(ds.cbind.o(x="as_list", DataSHIELD.checks=TRUE), " Only objects of type 'data.frame', 'matrix', 'numeric', 'integer', 'character', 'factor' and 'logical' are allowed.", fixed=TRUE)
})

#
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-arg-ds.dataFrame.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ connect.smk.dataset.sim(list("LAB_TSC"))
context("ds.dataFrame.o::arg::test errors")
test_that("dataFrame_erros", {
expect_error(ds.dataFrame.o(), "Please provide the name of the list that holds the input vectors!", fixed=TRUE)

ds.asList.o(x='D$A', newobj="as_list")
expect_error(ds.dataFrame.o("as_list", DataSHIELD.checks=TRUE), " Only objects of type 'data.frame', 'matrix', 'numeric', 'integer', 'character', 'factor' and 'logical' are allowed.", fixed=TRUE)
})

#
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-arg-ds.dim.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ connect.smk.dataset.sim(list("LAB_TSC"))
context("ds.dim.o::arg::test errors")
test_that("dim_erros", {
expect_error(ds.dim.o(), "Please provide a the name of a data.frame or matrix!", fixed=TRUE)
expect_error(ds.dim.o(check=TRUE), "Please provide a the name of a data.frame or matrix!", fixed=TRUE)
expect_error(ds.dim.o(x="F", checks = TRUE), "The input object must be a table structure!", fixed=TRUE)
expect_error(ds.dim.o(x="D", type = "other"), 'Function argument "type" has to be either "both", "combine" or "split"', fixed=TRUE)
})

#
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-arg-ds.glm.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ connect.smk.dataset.sim(list("LAB_TSC"))
context("ds.glm.o::arg::test errors")
test_that("glm_erros", {
expect_error(ds.glm.o(), " Please provide a valid regression formula!", fixed=TRUE)
expect_error(ds.glm.o("D$LAB_TSC~D$LAB_TSC"), " Please provide a valid 'family' argument!", fixed=TRUE)
})

#
Expand Down
5 changes: 2 additions & 3 deletions tests/testthat/test-arg-ds.length.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ connect.smk.dataset.sim(list("LAB_TSC"))

context("ds.length.o::arg::test errors")
test_that("length_erros", {
ds.asCharacter.o(x='D$LAB_TSC', newobj="not_a_numeric")
ds.asMatrix.o(x='D$LAB_TSC', newobj="not_a_numeric")

expect_error(ds.length.o(), "Please provide the name of the input vector!", fixed=TRUE)
expect_error(ds.length.o(x='D$LAB_TSC', type='datashield'), 'Function argument "type" has to be either "both", "combine" or "split"', fixed=TRUE)
# expect_error(ds.length.o(x='not_a_numeric'), "The input object must be an integer or a numeric vector.", fixed=TRUE)
expect_error(ds.length.o(check=TRUE), "Please provide the name of the input vector!", fixed=TRUE)
expect_error(ds.length.o(x='D$LAB_TSC', type='datashield', check=TRUE), 'Function argument "type" has to be either "both", "combine" or "split"', fixed=TRUE)
# expect_error(ds.length.o(x='not_a_numeric', check=TRUE), "The input object must be an integer or a numeric vector.", fixed=TRUE)
expect_error(ds.length.o(x='not_a_numeric', checks=TRUE), "The input object must be a character, factor, integer, logical or numeric vector or a list.", fixed=TRUE)
})

#
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-arg-ds.matrixDet.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ connect.smk.dataset.sim(list("LAB_TSC"))
# Tests
#

context("ds.matrixDet.o::arg::test errors")
context("ds.matrixDet::arg::test errors")
test_that("matrixDet_erros", {
res <- ds.matrixDet()

Expand Down
14 changes: 13 additions & 1 deletion tests/testthat/test-arg-ds.mean.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,21 @@ test_that("mean_erros", {

expect_error(ds.mean.o(), "Please provide the name of the input vector!", fixed=TRUE)
expect_error(ds.mean.o(x='D$LAB_TSC', type='datashield'), 'Function argument "type" has to be either "both", "combine" or "split"', fixed=TRUE)
# expect_error(ds.mean.o(x='not_a_numeric'), "The input object must be an integer or a numeric vector.", fixed=TRUE)
expect_error(ds.mean.o(x='not_a_numeric', checks=TRUE), "The input object must be an integer or a numeric vector.", fixed=TRUE)
})

#context("ds.mean.o::arg::discordant errors")
#test_that("mean_discordant", {
# res <- ds.mean.o("D$A")
#
# print("====")
# print(res)
# print("====")
#
# expect_length(res, 1)
# expect_equal(res, "")
#})

#
# Done
#
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-arg-ds.var.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ connect.smk.dataset.sim(list("LAB_TSC"))

context("ds.var.o::arg::test errors")
test_that("var_erros", {
ds.asCharacter.o(x='D$LAB_TSC', newobj="not_a_numeric")

expect_error(ds.var.o(), "Please provide the name of the input vector!", fixed=TRUE)
expect_error(ds.var.o(x="not_a_numeric", checks=TRUE), "The input object must be an integer or a numeric vector.", fixed=TRUE)
})

#
Expand Down
46 changes: 42 additions & 4 deletions tests/testthat/test-smk-ds.cor.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ connect.smk.dataset.survival(list("survtime", "time.id", "female"))

context("ds.cor.o::smk")

test_that("simple test, combine", {
res <- ds.cor.o(x="D$survtime", y="D$time.id", type="combine")
test_that("simple test, combine, pairwise.complete", {
res <- ds.cor.o(x="D$survtime", y="D$time.id", type="combine", naAction="pairwise.complete")

expect_length(res, 5)
expect_equal(class(res$`Number of missing values in each variable`), "matrix")
Expand All @@ -40,8 +40,22 @@ test_that("simple test, combine", {
expect_equal(res$`Error message`[[3]], NA)
})

test_that("simple test, split", {
res <- ds.cor.o(x="D$survtime", y="D$time.id", type="split")
test_that("simple test, combine, casewise.complete", {
res <- ds.cor.o(x="D$survtime", y="D$time.id", type="combine", naAction="casewise.complete")

expect_length(res, 5)
expect_equal(class(res$`Number of missing values in each variable`), "matrix")
expect_equal(class(res$`Number of missing values casewise`), "matrix")
expect_equal(class(res$`Correlation Matrix`), "matrix")
expect_equal(class(res$`Number of complete cases used`), "matrix")
expect_length(res$`Error message`, 3)
expect_equal(res$`Error message`[[1]], NA)
expect_equal(res$`Error message`[[2]], NA)
expect_equal(res$`Error message`[[3]], NA)
})

test_that("simple test, split, pairwise.complete", {
res <- ds.cor.o(x="D$survtime", y="D$time.id", type="split", naAction="pairwise.complete")

expect_length(res, 3)
expect_length(res[[1]], 5)
Expand All @@ -64,6 +78,30 @@ test_that("simple test, split", {
expect_equal(res[[3]]$`Error message`, NA)
})

test_that("simple test, split, casewise.complete", {
res <- ds.cor.o(x="D$survtime", y="D$time.id", type="split", naAction="casewise.complete")

expect_length(res, 3)
expect_length(res[[1]], 5)
expect_equal(class(res[[1]]$`Number of missing values in each variable`), "matrix")
expect_equal(class(res[[1]]$`Number of missing values casewise`), "matrix")
expect_equal(class(res[[1]]$`Correlation Matrix`), "matrix")
expect_equal(class(res[[1]]$`Number of complete cases used`), "matrix")
expect_equal(res[[1]]$`Error message`, NA)
expect_length(res[[2]], 5)
expect_equal(class(res[[2]]$`Number of missing values in each variable`), "matrix")
expect_equal(class(res[[2]]$`Number of missing values casewise`), "matrix")
expect_equal(class(res[[2]]$`Correlation Matrix`), "matrix")
expect_equal(class(res[[2]]$`Number of complete cases used`), "matrix")
expect_equal(res[[2]]$`Error message`, NA)
expect_length(res[[3]], 5)
expect_equal(class(res[[3]]$`Number of missing values in each variable`), "matrix")
expect_equal(class(res[[3]]$`Number of missing values casewise`), "matrix")
expect_equal(class(res[[3]]$`Correlation Matrix`), "matrix")
expect_equal(class(res[[3]]$`Number of complete cases used`), "matrix")
expect_equal(res[[3]]$`Error message`, NA)
})

#
# Done
#
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-smk-ds.cov.o.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test_that("simple test, split", {
expect_equal(res[[3]]$`Error message`, NA)
})

test_that("simple test, split", {
test_that("simple test, combine", {
res <- ds.cov.o(x="D$survtime", y="D$time.id", type="combine")

expect_length(res, 5)
Expand Down

0 comments on commit 2e584d8

Please sign in to comment.