-
Notifications
You must be signed in to change notification settings - Fork 8
/
test-tools-pipeline.R
74 lines (72 loc) · 2.7 KB
/
test-tools-pipeline.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# LIBS
library(testthat)
# VARS
wd <- tempdir()
# RUNNING
context('Testing \'setup-tools\'')
phylotaR:::cleanup(wd)
test_that('blast_setup() works', {
# test with fake system
res <- with_mock(
`phylotaR::outfmt_get` = function(...) '',
`phylotaR:::cmdln` = phylotaR:::cmdln_blastcheck,
phylotaR:::blast_setup(d = '.', v = FALSE, wd = wd, otsdr = FALSE)
)
expect_true(length(res) == 2)
# make sure wrong versions are flagged
res <- with_mock(
`phylotaR::outfmt_get` = function(...) '',
`phylotaR:::cmdln` = phylotaR:::cmdln_blastcheck,
expect_error(phylotaR:::blast_setup(d = 'wrngvrsn', v = FALSE,
wd = wd, otsdr = FALSE))
)
# make sure wrong dirs are flagged
expect_error(phylotaR:::blast_setup(d = '.', v = FALSE, wd = NULL,
otsdr = FALSE))
})
test_that('parameters_setup() works', {
expect_error(phylotaR:::parameters_setup(wd = wd, txid = 9606,
ncbi_execs = c('', '')))
ncbi_execs <- list('mkblstdb' = NA, 'blstn' = NA)
with_mock(
`phylotaR::outfmt_get` = function(...) '',
phylotaR:::parameters_setup(wd = wd, txid = 9606, ncbi_execs = ncbi_execs)
)
ps <- phylotaR:::parameters_load(wd = wd)
expect_true(length(ps) == 22)
})
phylotaR:::cleanup(wd)
test_that('stage_args_check() works', {
expect_error(phylotaR:::stage_args_check(frm = -1, to = -1))
expect_error(phylotaR:::stage_args_check(frm = 5, to = 5))
expect_error(phylotaR:::stage_args_check(frm = 2, to = 1))
res <- phylotaR:::stage_args_check(frm = 1, to = 4)
expect_true(res == 'Running stages: taxise, download, cluster, cluster2')
res <- phylotaR:::stage_args_check(frm = 4, to = 4)
expect_true(res == 'Running stages: cluster2')
})
test_that('stages_run() works', {
res <- with_mock(
`phylotaR::outfmt_get` = function(...) '',
`phylotaR::cmdln` = phylotaR:::cmdln_blastcheck,
`phylotaR:::taxise_run` = function(...){NULL},
`phylotaR:::download_run` = function(...){NULL},
`phylotaR:::clusters_run` = function(...){NULL},
`phylotaR:::clusters2_run` = function(...){NULL},
phylotaR::setup(wd = wd, txid = 9606),
phylotaR:::stages_run(wd = wd, to = 4, frm = 1, stgs_msg = '',
rstrt = FALSE)
)
expect_null(res)
res <- with_mock(
`phylotaR:::taxise_run` = function(...){NULL},
`phylotaR:::download_run` = function(...){NULL},
`phylotaR:::clusters_run` = function(...){NULL},
`phylotaR:::clusters2_run` = function(...){NULL},
phylotaR:::stages_run(wd = wd, to = 4, frm = 1, stgs_msg = '',
rstrt = TRUE)
)
expect_null(res)
phylotaR:::cleanup(wd)
})
phylotaR:::cleanup(wd)