Skip to content

Commit

Permalink
Merge pull request #145 from RobLBaker/main
Browse files Browse the repository at this point in the history
unit tests for set_new_creators
  • Loading branch information
RobLBaker authored Jun 26, 2024
2 parents f8d0d07 + 1977267 commit 59c36f7
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# EMLeditor v0.1.6 (in progress)
## 2024-06-26
* Added new function, `set_new_creator()` which can add one or more creators to EML.
## 2024-05-01
* Fix documentation: typo/formatting for the description of `set_int_rights()` in the EML Creation Script github.io page.
## 2024-04-29
Expand Down
2 changes: 1 addition & 1 deletion R/editEMLfunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@ set_new_creator <- function(eml_object,
if (NPS == TRUE) {
eml_object <- .set_npspublisher(eml_object)
}
# add/update EMLeditor and version to metadataa
# add/update EMLeditor and version to metadata
eml_object <- .set_version(eml_object)

return(eml_object)
Expand Down
5 changes: 3 additions & 2 deletions docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ articles:
a03_Template_edits: a03_Template_edits.html
a04_Editing_fixing_eml: a04_Editing_fixing_eml.html
a05_advanced_functionality: a05_advanced_functionality.html
last_built: 2024-06-26T20:03Z
last_built: 2024-06-26T21:30Z
urls:
reference: https://nationalparkservice.github.io/EMLeditor/reference
article: https://nationalparkservice.github.io/EMLeditor/articles
Expand Down
2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

30 changes: 28 additions & 2 deletions tests/testthat/test-editEMLfunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
good_dir <- here::here("good")
bad_dir <- here::here("bad")

#load metadata to to test functions with. Note that this directory structire is necessary to pass Rstudio Build Checks but will not work for local test developmnet and test testing.
#to test/debug the tests, use the following directory structure:
#good_dir <- here::here("tests", "testthat", "good")

#load metadata to to test functions with. Note that this directory structure is necessary to pass Rstudio Build Checks but will not work for local test development and test testing.
BICY_EMLed_meta <- EML::read_eml(here::here(good_dir,
"BICY",
"BICY_EMLeditor_metadata.xml"),
Expand Down Expand Up @@ -919,7 +922,7 @@ test_that("set_creator_orcids does not add orcids when requested not to", {
})
})

# ----- set_creator_orgs ----
# ----- test set_creator_orgs ----

test_that("set_creator_orgs returns valid EML", {
new_meta <- set_creator_orgs(BICY_EMLed_meta,
Expand Down Expand Up @@ -947,6 +950,29 @@ test_that("set_creator_orgs adds organization when force = FALSE", {
2)
})

# ----- test set_new_creator ----

test_that("set_new_creator returns valid EML", {
new_meta <- set_new_creator(BICY_EMLed_meta,
last_name = c("Doe", "Smith"),
first_name = c("John", "Jane"),
middle_name = c(NA, "S."),
organization_name = c("NPS", "UCLA"),
email_address = c("john_doe@@nps.gov", NA))
expect_equal(EML::eml_validate(new_meta)[1], TRUE)
})

test_that("set_new_creator adds creators to EML", {
new_meta <- set_new_creator(BICY_EMLed_meta,
last_name = c("Doe", "Smith"),
first_name = c("John", "Jane"),
middle_name = c(NA, "S."),
organization_name = c("NPS", "UCLA"),
email_address = c("john_doe@@nps.gov", NA))
creator <- new_meta[["dataset"]][["creator"]]
expect_equal(length(seq_along(creator)), 3)
})

# ----- test set_creator_order ----

test_that("set_creator_order returns valid EML", {
Expand Down

0 comments on commit 59c36f7

Please sign in to comment.