|
| 1 | +#------------------------------------------------------------------------------- |
| 2 | +# Copyright (c) 2019-2020 University of Newcastle upon Tyne. All rights reserved. |
| 3 | +# |
| 4 | +# This program and the accompanying materials |
| 5 | +# are made available under the terms of the GNU Public License v3.0. |
| 6 | +# |
| 7 | +# You should have received a copy of the GNU General Public License |
| 8 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 9 | +#------------------------------------------------------------------------------- |
| 10 | + |
| 11 | +# |
| 12 | +# Set up |
| 13 | +# |
| 14 | + |
| 15 | +context("ds.getWGSR::smk::setup") |
| 16 | + |
| 17 | +connect.studies.dataset.anthro(list("age", "sex", "weight", "height", "muac")) |
| 18 | + |
| 19 | +test_that("setup", { |
| 20 | + ds_expect_variables(c("D")) |
| 21 | +}) |
| 22 | + |
| 23 | +# |
| 24 | +# Tests |
| 25 | +# |
| 26 | + |
| 27 | +context("ds.getWGSR::smk") |
| 28 | +test_that("simple getWGSR", { |
| 29 | + res <- ds.getWGSR('D$sex', 'D$weight', 'D$height', 'wfh', newobj='newobj.getwgsr') |
| 30 | + |
| 31 | + expect_length(res, 2) |
| 32 | + expect_length(res$is.object.created, 1) |
| 33 | + expect_equal(res$is.object.created, "A data object <newobj.getwgsr> has been created in all specified data sources") |
| 34 | + expect_length(res$validity.check, 1) |
| 35 | + expect_equal(res$validity.check, "<newobj.getwgsr> appears valid in all sources") |
| 36 | + |
| 37 | + res.class <- ds.class('newobj.getwgsr') |
| 38 | + |
| 39 | + expect_length(res.class, 3) |
| 40 | + expect_length(res.class$study1, 1) |
| 41 | + expect_equal(res.class$study1, 'numeric') |
| 42 | + expect_length(res.class$study2, 1) |
| 43 | + expect_equal(res.class$study2, 'numeric') |
| 44 | + expect_length(res.class$study3, 1) |
| 45 | + expect_equal(res.class$study3, 'numeric') |
| 46 | + |
| 47 | + res.length <- ds.length('newobj.getwgsr') |
| 48 | + |
| 49 | + expect_length(res.length, 4) |
| 50 | + expect_length(res.length$`length of newobj.getwgsr in study1`, 1) |
| 51 | + expect_equal(res.length$`length of newobj.getwgsr in study1`, 873) |
| 52 | + expect_length(res.length$`length of newobj.getwgsr in study2`, 1) |
| 53 | + expect_equal(res.length$`length of newobj.getwgsr in study2`, 796) |
| 54 | + expect_length(res.length$`length of newobj.getwgsr in study3`, 1) |
| 55 | + expect_equal(res.length$`length of newobj.getwgsr in study3`, 221) |
| 56 | + expect_length(res.length$`total length of newobj.getwgsr in all studies combined`, 1) |
| 57 | + expect_equal(res.length$`total length of newobj.getwgsr in all studies combined`, 1890) |
| 58 | +}) |
| 59 | + |
| 60 | +# |
| 61 | +# Done |
| 62 | +# |
| 63 | + |
| 64 | +context("ds.getWGSR::smk::shutdown") |
| 65 | + |
| 66 | +test_that("shutdown", { |
| 67 | + ds_expect_variables(c("D", "newobj.getwgsr")) |
| 68 | +}) |
| 69 | + |
| 70 | +disconnect.studies.dataset.cnsim() |
| 71 | + |
| 72 | +context("ds.getWGSR::smk::done") |
0 commit comments