|
1 | 1 | context("Instruments") |
2 | 2 |
|
3 | | -test_that("server and mrinstruments", { |
| 3 | +skip_if_offline() |
| 4 | +skip_if_offline(host = "api.opengwas.io") |
| 5 | +skip_on_cran() |
4 | 6 |
|
5 | | - skip("Skip unless you have good access to the API.") |
6 | | - |
| 7 | +test_that("server and mrinstruments 1", { |
7 | 8 | # no no |
8 | | - exp_dat <- extract_instruments(outcomes=c("ieu-a-1032")) |
| 9 | + exp_dat <- try(extract_instruments(outcomes=c("ieu-a-1032"))) |
| 10 | + if (class(exp_dat) == "try-error") skip("Server issues") |
9 | 11 | expect_true(length(unique(exp_dat$id)) == 0) |
| 12 | +}) |
| 13 | + |
10 | 14 |
|
| 15 | +test_that("server and mrinstruments 2", { |
11 | 16 | # no yes |
12 | | - exp_dat <- extract_instruments(outcomes=c("ebi-a-GCST004634")) |
| 17 | + exp_dat <- try(extract_instruments(outcomes=c("ebi-a-GCST004634"))) |
| 18 | + if (class(exp_dat) == "try-error") skip("Server issues") |
13 | 19 | expect_true(length(unique(exp_dat$id)) == 1) |
14 | | - |
| 20 | +}) |
| 21 | + |
| 22 | +test_that("server and mrinstruments 3", { |
15 | 23 | # yes no |
16 | | - exp_dat <- extract_instruments(outcomes=c("ieu-a-2", "ieu-a-1032")) |
| 24 | + exp_dat <- try(extract_instruments(outcomes=c("ieu-a-2", "ieu-a-1032"))) |
| 25 | + if (class(exp_dat) == "try-error") skip("Server issues") |
17 | 26 | expect_true(length(unique(exp_dat$id)) == 1) |
| 27 | +}) |
18 | 28 |
|
| 29 | +test_that("server and mrinstruments 4", { |
19 | 30 | # yes yes |
20 | | - exp_dat <- extract_instruments(outcomes=c("ieu-a-2", "ebi-a-GCST004634")) |
| 31 | + exp_dat <- try(extract_instruments(outcomes=c("ieu-a-2", "ebi-a-GCST004634"))) |
| 32 | + if (class(exp_dat) == "try-error") skip("Server issues") |
21 | 33 | expect_true(length(unique(exp_dat$id)) == 2) |
| 34 | +}) |
22 | 35 |
|
23 | | - exp_dat <- extract_instruments(outcomes=c("ieu-a-1032", "ebi-a-GCST004634")) |
| 36 | +test_that("server and mrinstruments 5", { |
| 37 | + exp_dat <- try(extract_instruments(outcomes=c("ieu-a-1032", "ebi-a-GCST004634"))) |
| 38 | + if (class(exp_dat) == "try-error") skip("Server issues") |
24 | 39 | expect_true(length(unique(exp_dat$id)) == 1) |
| 40 | +}) |
25 | 41 |
|
26 | | - exp_dat <- extract_instruments(outcomes=c(2,100,"ieu-a-1032",104,72,999)) |
| 42 | +test_that("server and mrinstruments 6", { |
| 43 | + exp_dat <- try(extract_instruments(outcomes=c(2,100,"ieu-a-1032",104,72,999))) |
| 44 | + if (class(exp_dat) == "try-error") skip("Server issues") |
27 | 45 | expect_true(length(unique(exp_dat$id)) == 5) |
| 46 | +}) |
28 | 47 |
|
29 | | - exp_dat <- extract_instruments(outcomes=c(2,100,"ieu-a-1032",104,72,999, "ebi-a-GCST004634")) |
| 48 | +test_that("server and mrinstruments 7", { |
| 49 | + exp_dat <- try(extract_instruments(outcomes=c(2,100,"ieu-a-1032",104,72,999, "ebi-a-GCST004634"))) |
| 50 | + if (class(exp_dat) == "try-error") skip("Server issues") |
30 | 51 | expect_true(length(unique(exp_dat$id)) == 6) |
31 | 52 | }) |
32 | 53 |
|
33 | 54 | load(system.file("extdata", "test_commondata.RData", package="TwoSampleMR")) |
34 | 55 |
|
35 | 56 | test_that("read data", { |
36 | | - # exp_dat <- extract_instruments("ieu-a-2") |
| 57 | + exp_dat <- try(extract_instruments("ieu-a-2")) |
| 58 | + if (class(exp_dat) == "try-error") skip("Server issues") |
37 | 59 | names(exp_dat) <- gsub(".exposure", "", names(exp_dat)) |
38 | 60 | fn <- tempfile() |
39 | 61 | write.table(exp_dat, file=fn, row=FALSE, col=TRUE, qu=FALSE, sep="\t") |
|
0 commit comments