Skip to content

Commit 2aa71ad

Browse files
committed
test: updated tests following refactor
1 parent fa381c1 commit 2aa71ad

8 files changed

Lines changed: 33 additions & 43 deletions

tests/testthat/test-arg-ds.cor.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
2222
# context("ds.cor::arg::test errors")
2323
test_that("cor_erros", {
2424
expect_error(ds.cor(), 'x=NULL. Please provide the name of a matrix or dataframe or the names of two numeric vectors!', fixed=TRUE)
25-
expect_error(ds.cor(x='D$LAB_TSC'), 'If x is a numeric vector, y must be a numeric vector!', fixed=TRUE)
25+
26+
expect_error(ds.cor(x='D$LAB_TSC'), "There are some DataSHIELD errors, list them with datashield.errors()", fixed=TRUE)
27+
res.errors <- DSI::datashield.errors()
28+
expect_match(res.errors[[1]], "If x is a numeric vector, y must be a numeric vector!")
29+
2630
expect_error(ds.cor(x='D$LAB_TSC', y='D$LAB_TRIG', type='datashield'), 'Function argument "type" has to be either "combine" or "split"', fixed=TRUE)
2731
})
2832

tests/testthat/test-arg-ds.cov.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG"))
2222
# context("ds.cov::arg::test errors")
2323
test_that("cov_erros", {
2424
expect_error(ds.cov(), 'x=NULL. Please provide the name of a matrix or dataframe or the names of two numeric vectors!', fixed=TRUE)
25-
expect_error(ds.cov(x='D$LAB_TSC'), 'If x is a numeric vector, y must be a numeric vector!', fixed=TRUE)
25+
26+
expect_error(ds.cov(x='D$LAB_TSC'), "There are some DataSHIELD errors, list them with datashield.errors()", fixed=TRUE)
27+
res.errors <- DSI::datashield.errors()
28+
expect_match(res.errors[[1]], "If x is a numeric vector, y must be a numeric vector!")
29+
2630
expect_error(ds.cov(x='D$LAB_TSC', y='D$LAB_TRIG', type='datashield'), 'Function argument "type" has to be either "combine" or "split"', fixed=TRUE)
2731
})
2832

tests/testthat/test-arg-ds.mean.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ test_that("mean_erros", {
2525

2626
expect_error(ds.mean(), "Please provide the name of the input object!", fixed=TRUE)
2727
expect_error(ds.mean(x='D$LAB_TSC', type='datashield'), 'Function argument "type" has to be either "both", "combine" or "split"', fixed=TRUE)
28-
expect_error(ds.mean(x='not_a_numeric', checks=TRUE), "The input object must be an integer or a numeric vector.", fixed=TRUE)
28+
29+
res.errors <- DSI::datashield.errors()
30+
expect_error(ds.mean(x='not_a_numeric'), "There are some DataSHIELD errors, list them with datashield.errors()", fixed=TRUE)
31+
res.errors <- DSI::datashield.errors()
32+
expect_match(res.errors[[1]], "must be of type numeric or integer")
2933
})
3034

3135
#context("ds.mean::arg::discordant errors")

tests/testthat/test-arg-ds.quantileMean.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ ds.asCharacter(x='D$LAB_HDL', newobj="not_a_numeric")
2424
test_that("quantileMean_erros", {
2525
expect_error(ds.quantileMean(), "Please provide the name of the input vector!", fixed=TRUE)
2626
expect_error(ds.quantileMean(x='D$LAB_HDL', type='datashield'), 'Function argument "type" has to be either "combine" or "split"', fixed=TRUE)
27-
expect_error(ds.quantileMean(x='not_a_numeric'), "The input object must be an integer or numeric vector.", fixed=TRUE)
27+
28+
expect_error(ds.quantileMean(x='not_a_numeric'), "There are some DataSHIELD errors, list them with datashield.errors()", fixed=TRUE)
29+
res.errors <- DSI::datashield.errors()
30+
expect_match(res.errors[[1]], "must be of type numeric or integer")
2831
})
2932

3033
#

tests/testthat/test-arg-ds.var.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ test_that("var_erros", {
2424
ds.asCharacter(x='D$LAB_TSC', newobj="not_a_numeric")
2525

2626
expect_error(ds.var(), "Please provide the name of the input object!", fixed=TRUE)
27-
expect_error(ds.var(x="not_a_numeric", checks=TRUE), "The input object must be an integer or a numeric vector.", fixed=TRUE)
27+
28+
expect_error(ds.var(x="not_a_numeric"), "There are some DataSHIELD errors, list them with datashield.errors()", fixed=TRUE)
29+
res.errors <- DSI::datashield.errors()
30+
expect_match(res.errors[[1]], "must be of type numeric or integer")
2831
})
2932

3033
#

tests/testthat/test-smk-ds.completeCases-vectors.R

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ test_that("setup", {
2929
test_that("completeCases vector", {
3030
ds.c("D$survtime", newobj="vec_n")
3131

32-
res.completeCases <- ds.completeCases("vec_n", "vec_n_new")
33-
34-
expect_length(res.completeCases, 2)
35-
expect_equal(res.completeCases$is.object.created, "A data object <vec_n_new> has been created in all specified data sources")
36-
expect_equal(res.completeCases$validity.check, "<vec_n_new> appears valid in all sources")
32+
ds.completeCases("vec_n", "vec_n_new")
3733

3834
res.vec.class <- ds.class("vec_n")
3935

@@ -84,11 +80,7 @@ test_that("completeCases vector", {
8480
test_that("completeCases vector", {
8581
ds.asInteger("D$age.60", newobj="vec_i")
8682

87-
res.completeCases <- ds.completeCases("vec_i", "vec_i_new")
88-
89-
expect_length(res.completeCases, 2)
90-
expect_equal(res.completeCases$is.object.created, "A data object <vec_i_new> has been created in all specified data sources")
91-
expect_equal(res.completeCases$validity.check, "<vec_i_new> appears valid in all sources")
83+
ds.completeCases("vec_i", "vec_i_new")
9284

9385
res.vec.class <- ds.class("vec_i")
9486

@@ -139,11 +131,7 @@ test_that("completeCases vector", {
139131
test_that("completeCases vector", {
140132
ds.asCharacter("D$age.60", newobj="vec_c")
141133

142-
res.completeCases <- ds.completeCases("vec_c", "vec_c_new")
143-
144-
expect_length(res.completeCases, 2)
145-
expect_equal(res.completeCases$is.object.created, "A data object <vec_c_new> has been created in all specified data sources")
146-
expect_equal(res.completeCases$validity.check, "<vec_c_new> appears valid in all sources")
134+
ds.completeCases("vec_c", "vec_c_new")
147135

148136
res.vec.class <- ds.class("vec_c")
149137

@@ -194,11 +182,7 @@ test_that("completeCases vector", {
194182
test_that("completeCases vector", {
195183
ds.asLogical("D$age.60", newobj="vec_l")
196184

197-
res.completeCases <- ds.completeCases("vec_l", "vec_l_new")
198-
199-
expect_length(res.completeCases, 2)
200-
expect_equal(res.completeCases$is.object.created, "A data object <vec_l_new> has been created in all specified data sources")
201-
expect_equal(res.completeCases$validity.check, "<vec_l_new> appears valid in all sources")
185+
ds.completeCases("vec_l", "vec_l_new")
202186

203187
res.vec.class <- ds.class("vec_l")
204188

@@ -249,11 +233,7 @@ test_that("completeCases vector", {
249233
test_that("completeCases vector", {
250234
ds.c("D$female", newobj="vec_f")
251235

252-
res.completeCases <- ds.completeCases("vec_f", "vec_f_new")
253-
254-
expect_length(res.completeCases, 2)
255-
expect_equal(res.completeCases$is.object.created, "A data object <vec_f_new> has been created in all specified data sources")
256-
expect_equal(res.completeCases$validity.check, "<vec_f_new> appears valid in all sources")
236+
ds.completeCases("vec_f", "vec_f_new")
257237

258238
res.vec.class <- ds.class("vec_f")
259239

tests/testthat/test-smk-ds.completeCases.R

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ test_that("setup", {
2929
test_that("completeCases data.frame", {
3030
ds.dataFrame(c("D$LAB_TSC", "D$LAB_TRIG", "D$LAB_HDL", "D$LAB_GLUC_ADJUSTED", "D$PM_BMI_CONTINUOUS", "D$DIS_CVA", "D$MEDI_LPD", "D$DIS_DIAB", "D$DIS_AMI", "D$GENDER", "D$PM_BMI_CATEGORICAL"), newobj="df")
3131

32-
res.completeCases <- ds.completeCases("df", "df_new")
33-
34-
expect_length(res.completeCases, 2)
35-
expect_equal(res.completeCases$is.object.created, "A data object <df_new> has been created in all specified data sources")
36-
expect_equal(res.completeCases$validity.check, "<df_new> appears valid in all sources")
32+
ds.completeCases("df", "df_new")
3733

3834
res.df.class <- ds.class("df")
3935

@@ -86,11 +82,7 @@ test_that("completeCases data.frame", {
8682
test_that("completeCases matrix", {
8783
ds.asDataMatrix("D", newobj="mat")
8884

89-
res.completeCases <- ds.completeCases("mat", "mat_new")
90-
91-
expect_length(res.completeCases, 2)
92-
expect_equal(res.completeCases$is.object.created, "A data object <mat_new> has been created in all specified data sources")
93-
expect_equal(res.completeCases$validity.check, "<mat_new> appears valid in all sources")
85+
ds.completeCases("mat", "mat_new")
9486

9587
res.mat.class <- ds.class("mat")
9688

tests/testthat/test-smk-ds.length.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ test_that("basic length, combine", {
5353
})
5454

5555
test_that("basic length, both", {
56-
res.length <- ds.length('D$LAB_TSC', type='both', check=TRUE)
56+
res.length <- ds.length('D$LAB_TSC', type='both')
5757

5858
expect_length(res.length, 4)
5959
expect_equal(res.length$`length of D$LAB_TSC in sim1`, 2163)
@@ -63,7 +63,7 @@ test_that("basic length, both", {
6363
})
6464

6565
test_that("basic length, split", {
66-
res.length <- ds.length('D$LAB_TSC', type='split', check=TRUE)
66+
res.length <- ds.length('D$LAB_TSC', type='split')
6767

6868
expect_length(res.length, 3)
6969
expect_equal(res.length$`length of D$LAB_TSC in sim1`, 2163)
@@ -72,7 +72,7 @@ test_that("basic length, split", {
7272
})
7373

7474
test_that("basic length, combine", {
75-
res.length <- ds.length('D$LAB_TSC', type='combine', check=TRUE)
75+
res.length <- ds.length('D$LAB_TSC', type='combine')
7676

7777
expect_length(res.length, 1)
7878
expect_equal(res.length$`total length of D$LAB_TSC in all studies combined`, 9379)

0 commit comments

Comments
 (0)