generated from EcologyR/templateRpackage
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from EcologyR/new_tests
adding test to collection, tiny and herbarium functions
- Loading branch information
Showing
3 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
data <- data.frame(Field1 = c("Bombus", "Amata"), | ||
Field2 = c("Apidae", "Erebidae"), | ||
Field3 = c("05/09/92", "03/04/95"), | ||
Field4 = c("England", "Northern Ireland"), | ||
Field5 = c("Wasp-moth hybrid", "Produces fluid") | ||
) | ||
|
||
path <- tempdir() | ||
|
||
test_that("PDF file is created in the provided path", { | ||
|
||
skip_on_cran() | ||
skip_on_ci() | ||
|
||
create_collection_label(data, path = path, | ||
field1.column = "Field1", | ||
field2.column = "Field2", | ||
field3.column = "Field3", | ||
field4.column = "Field4", | ||
field5.column = "Field5") | ||
|
||
expect_true(file.exists(file.path(path, "Collection_label.pdf"))) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
|
||
|
||
data <- data.frame("ID"= "1", | ||
"Collector"= "Person1", | ||
"Collection_number"= "11.2", | ||
"Assistants"= "Person2, Person3", | ||
"Family"= "Canellae", | ||
"Taxon"= "Trorgssionis sp.1", | ||
"Author"= "L.", | ||
"det"= "Person1", | ||
"Det_date"= "1/1/2001", | ||
"life_form"= "shrub", | ||
"Observations"= "none", | ||
"Height"= "1m", | ||
"Location"= "AAAAA", | ||
"Area_description"= "AAAAA", | ||
"Elevation"= "314 m.a.s.l.", | ||
"Date"= "2/2/2002", | ||
"Latitude"= "1º2'3''W", | ||
"Longitude"= "1º2'3''N", | ||
"QR_code" = "https://powo.science.kew.org/results?q=Trorgssionis" | ||
) | ||
|
||
path <- tempdir() | ||
filename <- "labeleR_test" | ||
|
||
test_that("PDF certificates are created", { | ||
|
||
skip_on_ci() | ||
skip_on_cran() | ||
|
||
## Spanish | ||
create_herbarium_label(data = data, path = path, filename = filename, | ||
title ="example herbarium label" , | ||
subtitle = "is labeleR working correctly?", | ||
family.column = "Family", | ||
taxon.column = "Taxon", | ||
author.column = "Author", | ||
det.column = "det", | ||
date.det.column = "Det_date", | ||
location.column = "Location", | ||
area.description.column = "Area_description", | ||
latitude.column = "Latitude", | ||
longitude.column = "Longitude", | ||
elevation.column = "Elevation", | ||
field1.column = "life_form", | ||
field2.column = "Observations", | ||
field3.column = "Height", | ||
collector.column = "Collector", | ||
collection.column = "Collection_number", | ||
assistants.column = "Assistants", | ||
date.column = "Date" ) | ||
|
||
expect_true(file.exists(file.path(path, paste0(filename,".pdf")))) | ||
|
||
}) | ||
|
||
|
||
data <- data.frame("ID"= "1", | ||
"Collector"= "Person1", | ||
"Collection_number"= "11.2", | ||
"Assistants"= "Person2, Person3", | ||
"Family"= "Canellae", | ||
"Taxon"= "Trorgssionis sp.1", | ||
"Author"= "L.", | ||
"det"= "Person1", | ||
"Det_date"= "1/1/2001", | ||
"life_form"= "shrub", | ||
"Observations"= "Lorem ipsum dolor sit amet, consectetur adipiscing elit, | ||
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | ||
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | ||
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | ||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", | ||
"Height"= "1m", | ||
"Location"= "AAAAA", | ||
"Area_description"= "AAAAA", | ||
"Elevation"= "314 m.a.s.l.", | ||
"Date"= "2/2/2002", | ||
"Latitude"= "1º2'3''W", | ||
"Longitude"= "1º2'3''N", | ||
"QR_code" = "https://powo.science.kew.org/results?q=Trorgssionis" | ||
) | ||
|
||
path <- tempdir() | ||
filename <- "labeleR_test" | ||
|
||
test_that("PDF certificates are created", { | ||
|
||
skip_on_ci() | ||
skip_on_cran() | ||
|
||
## Spanish | ||
expect_message( | ||
create_herbarium_label(data = data, path = path, filename = filename, | ||
title ="example herbarium label" , | ||
subtitle = "is labeleR working correctly?", | ||
family.column = "Family", | ||
taxon.column = "Taxon", | ||
author.column = "Author", | ||
det.column = "det", | ||
date.det.column = "Det_date", | ||
location.column = "Location", | ||
area.description.column = "Area_description", | ||
latitude.column = "Latitude", | ||
longitude.column = "Longitude", | ||
elevation.column = "Elevation", | ||
field1.column = "life_form", | ||
field2.column = "Observations", | ||
field3.column = "Height", | ||
collector.column = "Collector", | ||
collection.column = "Collection_number", | ||
assistants.column = "Assistants", | ||
date.column = "Date", | ||
qr = "QR_code" | ||
) | ||
|
||
|
||
|
||
) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
data <- data.frame(Field1 = c("Bombus", "Amata"), | ||
Field2 = c("Apidae", "Erebidae"), | ||
Field3 = c("05/09/92", "03/04/95"), | ||
Field4 = c("England", "Northern Ireland"), | ||
Field5 = c("Wasp-moth hybrid", "Produces fluid") | ||
) | ||
|
||
path <- tempdir() | ||
|
||
test_that("PDF file is created in the provided path", { | ||
|
||
skip_on_cran() | ||
skip_on_ci() | ||
|
||
create_tinylabel (data, path = path, | ||
field1.column = "Field1", | ||
field2.column = "Field2", | ||
field3.column = "Field3", | ||
field4.column = "Field4", | ||
field5.column = "Field5") | ||
|
||
expect_true(file.exists(file.path(path, "Tiny_label.pdf"))) | ||
|
||
}) |