-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest-create_certificate.R
86 lines (75 loc) · 2.14 KB
/
test-create_certificate.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
75
76
77
78
79
80
81
82
83
84
85
86
test_that("create_certificate works", {
tdir <- withr::local_tempdir()
cert_path <- create_certificate(
"Test cohort",
first_name = "Jane",
last_name = "Doe",
start_date = "Oct 19",
end_date = "Dec 19",
cohort_website = "https://google.com",
output_dir = tdir
)
expect_true(file.exists(
file.path(tdir, "OpenscapesCertificate_Test-cohort_Jane-Doe.pdf")
))
})
test_that("create_certificate works with nmfs", {
tdir <- withr::local_tempdir()
cert_path <- create_certificate(
"NMFS Openscapes 2024",
first_name = "Jane",
last_name = "Doe",
start_date = "Oct 19",
end_date = "Dec 19",
cohort_website = "https://google.com",
cohort_type = "nmfs",
output_dir = tdir
)
expect_true(file.exists(
file.path(tdir, "OpenscapesCertificate_NMFS-Openscapes-2024_Jane-Doe.pdf")
))
})
test_that("create_batch_certificates works", {
tdir <- withr::local_tempdir()
participants <- dplyr::tibble(
cohort = c(
"2024-nmfs-champions-a",
"2024-nmfs-champions-a",
"2024-champions",
"2024-champions"
),
first = c("Sally", "Rupert", "Lily", "Leo"),
last = c("Green", "White", "Brown", "Blue")
)
registry <- dplyr::tibble(
cohort_name = c(
"2024-nmfs-champions-a",
"2024-nmfs-champions-b",
"2024-champions"
),
date_start = c("2024-01-01", "2024-05-05", "2024-10-10"),
date_end = c("2024-02-02", "2024-06-06", "2024-11-11"),
cohort_website = c(
"https://nmfs-openscapes.github.io/2024-nmfs-champions",
"https://nmfs-openscapes.github.io/2024-nmfs-champions",
"https://nasa-openscapes.github.io/2024-nasa-champions"
)
)
create_batch_certificates(
registry = registry,
participants = participants,
cohort_name = "2024-nmfs-champions-a",
cohort_type = "nmfs",
output_dir = file.path(tdir, "nmfs-a")
)
create_batch_certificates(
registry = registry,
participants = participants,
cohort_name = "2024-champions",
cohort_type = "nmfs",
output_dir = file.path(tdir, "nasa")
)
expect_snapshot(
list.files(tdir, recursive = TRUE)
)
})