Skip to content

Commit

Permalink
adding test to collection, tiny and herbarium functions [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
juliagdealedo committed Oct 20, 2023
1 parent 143d01a commit db276c4
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/testthat/test-collection_label.R
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")))

})
121 changes: 121 additions & 0 deletions tests/testthat/test-herbarium_label.R
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"
)



)

})
24 changes: 24 additions & 0 deletions tests/testthat/test-tinylabel.R
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")))

})

0 comments on commit db276c4

Please sign in to comment.