Skip to content

Commit

Permalink
inspire tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Jan 2, 2025
1 parent 4d092d3 commit 83b8c74
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions tests/testthat/test_INSPIREMetadataValidator.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ test_that("inspire - metadata validator",{
apiKey <- Sys.getenv("INSPIRE_API_KEY")
if(nzchar(apiKey)){
inspireValidator <- INSPIREMetadataValidator$new(url = Sys.getenv("INSPIRE_API_ENDPOINT"), apiKey = apiKey)
inspireReport <- inspireValidator$getValidationReport(obj = md, raw = TRUE)
if(inspireValidator$running){
expect_is(inspireReport, "list")
expect_equal(names(inspireReport), c("Status","Completeness","Test Run ID","Log", "Ref URI", "HTML Report", "raw"))
}else{
expect_null(inspireReport)
if(!is.null(inspireValidator)){
inspireReport <- inspireValidator$getValidationReport(obj = md, raw = TRUE)
if(inspireValidator$running){
expect_is(inspireReport, "list")
expect_equal(names(inspireReport), c("Status","Completeness","Test Run ID","Log", "Ref URI", "HTML Report", "raw"))
}else{
expect_null(inspireReport)
}
}
}else{
inspireValidator <- INSPIREMetadataValidator$new(url = Sys.getenv("INSPIRE_API_ENDPOINT"), apiKey = apiKey)
expect_error(inspireValidator$getValidationReport(obj = md, raw = TRUE))
if(!is.null(inspireValidator)){
expect_error(inspireValidator$getValidationReport(obj = md, raw = TRUE))
}
}
})

Expand All @@ -37,7 +41,7 @@ test_that("inspire - metadata validator 'encode' shortcut",{
apiKey <- Sys.getenv("INSPIRE_API_KEY")
if(nzchar(apiKey)){
inspireValidator <- INSPIREMetadataValidator$new(url = Sys.getenv("INSPIRE_API_ENDPOINT"), apiKey = apiKey)
xml <- md$encode(inspire = TRUE, inspireValidator = inspireValidator)
if(!is.null(inspireValidator)) xml <- md$encode(inspire = TRUE, inspireValidator = inspireValidator)
}
})

Expand All @@ -46,6 +50,6 @@ test_that("inspire - metadata validator 'save' shortcut",{
apiKey <- Sys.getenv("INSPIRE_API_KEY")
if(nzchar(apiKey)){
inspireValidator <- INSPIREMetadataValidator$new(url = Sys.getenv("INSPIRE_API_ENDPOINT"), apiKey = apiKey)
md$save("my-metadata.xml", inspire = TRUE, inspireValidator = inspireValidator)
if(!is.null(inspireValidator)) md$save("my-metadata.xml", inspire = TRUE, inspireValidator = inspireValidator)
}
})

0 comments on commit 83b8c74

Please sign in to comment.