-
Notifications
You must be signed in to change notification settings - Fork 7
/
test-download.R
50 lines (43 loc) · 1.28 KB
/
test-download.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
test_that("Require file", {
skip_if_offline()
expect_error(mx_download())
})
mx_result <-
data.frame(
link_pdf = "https://www.medrxiv.org/content/10.1101/19003301v4.full.pdf",
ID = "271",
doi = "10.1101/19003301"
)
tmpdir <- tempdir()
test_that("Inital output", {
skip_on_cran()
skip_if_offline()
expect_message(mx_download(mx_result, tmpdir), regexp = "Downloading")
})
test_that("Already downloaded", {
skip_on_cran()
skip_if_offline()
expect_message(mx_download(mx_result, tmpdir), regexp = "downloaded")
})
test_that("Naming of downloaded PDFs", {
skip_on_cran()
skip_if_offline()
mx_download(mx_result, tmpdir, name = "ID")
expect_equal(file.exists(paste0(tmpdir,"/271.pdf")), TRUE)
mx_download(mx_result, tmpdir, name = "DOI")
expect_equal(file.exists(paste0(tmpdir,"/271_10.1101_19003301.pdf")), TRUE)
})
mx_result <-
data.frame(
link_pdf = paste0("https://www.medrxiv.org/content/",
"10.1101/2020.09.23.20197558v1.full.pdf"),
ID = "272",
doi = "10.1101/2020.09.23.20197558")
test_that("Status update", {
skip_on_cran()
skip_if_offline()
expect_message(mx_download(mx_result,
tmpdir,
print_update = 1),
regexp = "%")
})