Skip to content

Commit 12f7817

Browse files
committed
Add 'deprecated' tests
1 parent 4cc7c7d commit 12f7817

5 files changed

Lines changed: 33 additions & 27 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test_that("setup", {
2727

2828
# context("ds.look::smk")
2929
test_that("simple look", {
30-
res <- ds.look("lengthDS('D$LAB_TSC')")
30+
res <- expect_warning(ds.look("lengthDS('D$LAB_TSC')"), "'ds.look' is deprecated.", fixed = TRUE)
3131

3232
expect_length(res, 1)
3333
expect_length(res$output, 3)

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ test_that("setup", {
2626
#
2727

2828
# context("ds.meanByClass::smk::LAB_TSC across PM_BMI_CATEGORICAL categories where both vectors are 'loose'")
29-
ds.assign("D$LAB_TSC", "ldl")
30-
ds.assign("D$PM_BMI_CATEGORICAL", "pm_bmi")
3129
test_that("LAB_TSC_across_", {
32-
res <- ds.meanByClass(x='ldl~pm_bmi')
30+
ds.assign("D$LAB_TSC", "ldl")
31+
ds.assign("D$PM_BMI_CATEGORICAL", "pm_bmi")
32+
33+
res <- expect_warning(ds.meanByClass(x='ldl~pm_bmi'), "'ds.meanByClass' is deprecated.", fixed = TRUE)
3334

3435
expect_length(res, 6)
3536
expect_equal(res[[1]], '2753')
@@ -41,8 +42,8 @@ test_that("LAB_TSC_across_", {
4142
})
4243

4344
# context("ds.meanByClass::smk::calculate the mean proportion for LAB_HDL across PM_BMI_CATEGORICAL categories")
44-
res <- ds.meanByClass(x='D', outvar='LAB_HDL', covar='PM_BMI_CATEGORICAL')
4545
test_that("LAB_HDL_across_PM_BMI_CATEGORICAL", {
46+
res <- expect_warning(ds.meanByClass(x='D', outvar='LAB_HDL', covar='PM_BMI_CATEGORICAL'), "'ds.meanByClass' is deprecated.", fixed = TRUE)
4647

4748
expect_length(res, 6)
4849
expect_equal(res[[1]], '2753')
@@ -55,8 +56,8 @@ test_that("LAB_HDL_across_PM_BMI_CATEGORICAL", {
5556

5657

5758
# context("ds.meanByClass::smk::calculate the mean proportion for LAB_HDL & LAB_TSC across bmi categories")
58-
res <- ds.meanByClass(x='D', outvar=c('LAB_HDL','LAB_TSC'), covar=c('PM_BMI_CATEGORICAL'))
5959
test_that("LAB_HDL-LAB_TSC_across_PM_BMI_CATEGORICAL", {
60+
res <- expect_warning(ds.meanByClass(x='D', outvar=c('LAB_HDL','LAB_TSC'), covar=c('PM_BMI_CATEGORICAL')), "'ds.meanByClass' is deprecated.", fixed = TRUE)
6061

6162
expect_length(res, 12)
6263
expect_equal(res[[1]], '2753')
@@ -77,10 +78,9 @@ test_that("LAB_HDL-LAB_TSC_across_PM_BMI_CATEGORICAL", {
7778
# context("ds.meanByClass::smk::calculate the mean proportion for LAB_HDL across gender bmi and diabetes status categories")
7879
# res <- ds.meanByClass(datasources=ds.test_env$connection.opal, x='D', outvar=c('LAB_HDL','LAB_TSC'), covar=c('GENDER','PM_BMI_CATEGORICAL','DIS_DIAB'))
7980

80-
8181
# context("ds.meanByClass::smk::calculate the mean proportion for LAB_HDL across PM_BMI_CATEGORICAL categories, split")
82-
res <- ds.meanByClass(x='D', outvar='LAB_HDL', covar='PM_BMI_CATEGORICAL', type='split')
8382
test_that("LAB_HDL_across_PM_BMI_CATEGORICAL", {
83+
res <- expect_warning(ds.meanByClass(x='D', outvar='LAB_HDL', covar='PM_BMI_CATEGORICAL', type='split'), "'ds.meanByClass' is deprecated.", fixed = TRUE)
8484

8585
expect_length(res, 3)
8686
expect_length(res$sim1, 6)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test_that("setup", {
2828

2929
# context("ds.message::smk")
3030
test_that("not exists - request message", {
31-
message.res <- ds.message('Test')
31+
message.res <- expect_warning(ds.message('Test'), "'ds.meanByClass' is deprecated.", fixed = TRUE)
3232

3333
expect_length(message.res, 3)
3434
expect_equal(message.res$sim1, "Error: the object <message.object.name> does not exist in this datasource", fixed=TRUE)
@@ -39,7 +39,7 @@ test_that("not exists - request message", {
3939
test_that("exists - request message", {
4040
ds.list("D$LAB_TSC", "Test")
4141

42-
message.res <- ds.message('Test')
42+
message.res <- expect_warning(ds.message('Test'), "'ds.meanByClass' is deprecated.", fixed = TRUE)
4343

4444
expect_length(message.res, 3)
4545
expect_equal(message.res$sim1, "ALL OK: there are no studysideMessage(s) on this datasource", fixed=TRUE)
@@ -52,7 +52,7 @@ test_that("partial - request message - conn 1", {
5252

5353
ds.list("D$LAB_TSC", newobj="TestP", datasources=ds.test_env$connections[1])
5454

55-
message.res <- ds.message('TestP')
55+
message.res <- expect_warning(ds.message('TestP'), "'ds.meanByClass' is deprecated.", fixed = TRUE)
5656

5757
expect_length(message.res, 3)
5858
expect_equal(message.res$sim1, "ALL OK: there are no studysideMessage(s) on this datasource", fixed=TRUE)
@@ -67,7 +67,7 @@ test_that("partial - request message - conn 2", {
6767

6868
ds.list("D$LAB_TSC", newobj="TestP", datasources=ds.test_env$connections[2])
6969

70-
message.res <- ds.message('TestP')
70+
message.res <- expect_warning(ds.message('TestP'), "'ds.meanByClass' is deprecated.", fixed = TRUE)
7171

7272
expect_length(message.res, 3)
7373
expect_equal(message.res$sim1, "Error: the object <message.object.name> does not exist in this datasource", fixed=TRUE)
@@ -82,7 +82,7 @@ test_that("partial - request message - conn 3", {
8282

8383
ds.list("D$LAB_TSC", newobj="TestP", datasources=ds.test_env$connections[3])
8484

85-
message.res <- ds.message('TestP')
85+
message.res <- expect_warning(ds.message('TestP'), "'ds.meanByClass' is deprecated.", fixed = TRUE)
8686

8787
expect_length(message.res, 3)
8888
expect_equal(message.res$sim1, "Error: the object <message.object.name> does not exist in this datasource", fixed=TRUE)

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,51 +26,57 @@ test_that("setup", {
2626
#
2727

2828
# context("ds.subset::smk::generate a subset of the assigned table (by default the table is named 'D') with the first 50 observations and the two first columns")
29-
ds.subset(datasources=ds.test_env$connections, subset='subD', x='D', rows=c(1:50), cols=c(1,2))
30-
res <- ds.exists('subD')
3129
test_that("subD_exists", {
30+
expect_warning(ds.subset(datasources=ds.test_env$connections, subset='subD', x='D', rows=c(1:50), cols=c(1,2)), "'ds.dataFrameSubset' is deprecated.", fixed = TRUE)
31+
32+
res <- ds.exists('subD')
33+
3234
expect_length(res, 3)
3335
expect_true(res$sim1)
3436
expect_true(res$sim2)
3537
expect_true(res$sim3)
3638
})
3739

3840
# context("ds.subset::smk::generate a subset of the assigned table (by default the table is named 'D') with the first 50 observations and the two first columns referred to by their names")
39-
ds.subset(subset='subD2', x='D', rows=c(1:50), cols = c('DIS_DIAB','PM_BMI_CONTINUOUS'))
40-
res <- ds.exists('subD2')
4141
test_that("subD2_exists", {
42+
expect_warning(ds.subset(subset='subD2', x='D', rows=c(1:50), cols = c('DIS_DIAB','PM_BMI_CONTINUOUS')), "'ds.dataFrameSubset' is deprecated.", fixed = TRUE)
43+
44+
res <- ds.exists('subD2')
45+
4246
expect_length(res, 3)
4347
expect_true(res$sim1)
4448
expect_true(res$sim2)
4549
expect_true(res$sim3)
4650
})
4751

4852
# context("ds.subset::smk::generate a subset of the table D with bmi values greater than or equal to 25.")
49-
ds.subset(datasources=ds.test_env$connections, subset='subD3', x='D', logical='PM_BMI_CONTINUOUS>=', threshold=25)
50-
res <- ds.exists('subD3')
5153
test_that("subD3_exists", {
54+
expect_warning(ds.subset(datasources=ds.test_env$connections, subset='subD3', x='D', logical='PM_BMI_CONTINUOUS>=', threshold=25), "'ds.dataFrameSubset' is deprecated.", fixed = TRUE)
55+
56+
res <- ds.exists('subD3')
57+
5258
expect_length(res, 3)
5359
expect_true(res$sim1)
5460
expect_true(res$sim2)
5561
expect_true(res$sim3)
5662
})
5763

5864
# context("ds.subset::smk::get the logarithmic values of the variable 'lab_hdl' and generate a subset with the first 50 observations of that new vector.")
59-
# ds.assign(toAssign='log(D$LAB_HDL)', newobj='logHDL')
60-
# ds.subset(datasources=ds.test_env$connections, subset="subLAB_HDL", x="logHDL", rows=c(1:50))
61-
# res <- ds.exists('subLAB_HDL')
6265
# test_that("subLAB_HDL_exists", {
66+
# ds.assign(toAssign='log(D$LAB_HDL)', newobj='logHDL')
67+
# ds.subset(datasources=ds.test_env$connections, subset="subLAB_HDL", x="logHDL", rows=c(1:50))
68+
# res <- ds.exists('subLAB_HDL')
6369
# expect_length(res, 3)
6470
# expect_true(res$sim1)
6571
# expect_true(res$sim2)
6672
# expect_true(res$sim3)
6773
# })
6874

6975
# context("ds.subset::smk::get the variable 'PM_BMI_CONTINUOUS' from the dataframe 'D' and generate a subset bmi vector with bmi values greater than or equal to 25")
70-
# ds.assign(toAssign='D$PM_BMI_CONTINUOUS', newobj='BMI')
71-
# ds.subset(datasources=ds.test_env$connections, subset='subBMI', x='BMI', logical='>=', threshold=25)
72-
# res <- ds.exists('subBMI')
7376
# test_that("subBMI_exists", {
77+
# ds.assign(toAssign='D$PM_BMI_CONTINUOUS', newobj='BMI')
78+
# ds.subset(datasources=ds.test_env$connections, subset='subBMI', x='BMI', logical='>=', threshold=25)
79+
# res <- ds.exists('subBMI')
7480
# expect_length(res, 3)
7581
# expect_true(res$sim1)
7682
# expect_true(res$sim2)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test_that("setup", {
2727

2828
# context("ds.subsetByClass::smk")
2929
test_that("gender implicit", {
30-
res <- ds.subsetByClass(x='D', subsets='subclasses1')
30+
res <- expect_warning(ds.subsetByClass(x='D', subsets='subclasses1'), "'ds.dataFrameSubset' is deprecated.", fixed = TRUE)
3131

3232
expect_true(is.null(res))
3333

@@ -46,7 +46,7 @@ test_that("gender implicit", {
4646
})
4747

4848
test_that("gender explicit", {
49-
res <- ds.subsetByClass(x='D', subsets='subclasses2', variables='GENDER')
49+
res <- expect_warning(ds.subsetByClass(x='D', subsets='subclasses2', variables='GENDER'), "'ds.dataFrameSubset' is deprecated.", fixed = TRUE)
5050

5151
expect_true(is.null(res))
5252

0 commit comments

Comments
 (0)