Skip to content

Commit

Permalink
fix #370 + integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Oct 11, 2023
1 parent 21ff716 commit ec5eb1f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
23 changes: 23 additions & 0 deletions inst/extdata/workflows/config_metadata_ncml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"profile": {
"id": "my-workflow",
"name": "My workflow",
"project": "Test geoflow project",
"organization": "My organization",
"logos": [
"https://via.placeholder.com/300x150.png/09f/fff?text=geoflow"
],
"mode": "entity"
},
"metadata": {
"entities": [
{
"handler": "ncml",
"source": "https://galilee.univ-reunion.fr/thredds/ncml/dataStations/La_Reunion/saintjosephmairie/saintjosephmairie_aggregated.ncml?catalog=https%3A%2F%2Fgalilee.univ-reunion.fr%2Fthredds%2Fcatalog%2FdataStations%2FLa_Reunion%2Fsaintjosephmairie%2Fcatalog.html&dataset=station%2FLa_Reunion%2Fsaintjosephmairie%2Fsaintjosephmairie_aggregated.ncml"
}
],
"contacts" : []
},
"software": [],
"actions": []
}
3 changes: 2 additions & 1 deletion inst/extdata/workflows/workflows.csv
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ config_metadata_gsheets_sdi_geoserver_geotiff_directory.json,Load metadata entit
config_metadata_ocs.json,Load metadata entities/contacts/dictionary from CSV files hosted on a cloud supporting OCS API (eg. nextcloud/owncloud)
config_metadata_dataverse.json,Load metadata entities/contacts from Dataverse records
config_metadata_zenodo.json,Load metadata entities/contacts from Zenodo deposits/records
config_metadata_zenodo_with_options.json,Load metadata entities/contacts from Zenodo deposits/records (with options declared to fetch from public records and by DOI)
config_metadata_zenodo_with_options.json,Load metadata entities/contacts from Zenodo deposits/records (with options declared to fetch from public records and by DOI)
config_metadata_ncml.json,Load a metadata entity/contacts from a NCML source
4 changes: 2 additions & 2 deletions inst/metadata/entity/entity_handler_ncml.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ handle_entities_ncml <- function(handler, source, config, handle = TRUE){


#identifiers
entity$setIdentifier("id", basename(source_name))
entity$setIdentifier("id", basename(attr$full_name$value))

doi <- attr$identifier_product_doi$value
if(!is.null(doi)){
Expand All @@ -98,7 +98,7 @@ handle_entities_ncml <- function(handler, source, config, handle = TRUE){
if(!is.null(title)){
entity$setTitle("title", title)
}else{
entity$setTitle("title",basename(source_name))
entity$setTitle("title",basename(attr$full_name$value))
}

#description
Expand Down
41 changes: 41 additions & 0 deletions tests/testthat/test_config_metadata_ncml.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# test_config_metadata_ncml.R
# Author: Emmanuel Blondel <emmanuel.blondel1@gmail.com>
#
# Description: Integration tests for config_metadata_ncml.json workflow
#=======================
require(geoflow, quietly = TRUE)
require(testthat)

#init
test_that("init",{
testthat::skip_on_cran()
cfg_file = system.file("extdata/workflows/config_metadata_ncml.json", package = "geoflow")
CFG <- geoflow::initWorkflow(cfg_file)
expect_is(CFG$metadata$content, "list")
expect_equal(length(CFG$metadata$content), 1L)
expect_equal(names(CFG$metadata$content), "entities")
expect_equal(length(CFG$metadata$content$entities), 1L)
expect_equal(length(CFG$getEntities()), 1L)
expect_equal(length(CFG$actions), 0L)
})

#debug
test_that("debug",{
testthat::skip_on_cran()
cfg_file = system.file("extdata/workflows/config_metadata_ncml.json", package = "geoflow")
DEBUG <- geoflow::debugWorkflow(cfg_file, entityIndex = 1, dir = ".")
expect_equal(names(DEBUG), c("config", "entity"))
expect_is(DEBUG$config, "list")
expect_is(DEBUG$entity, "geoflow_entity")
})

#execute
test_that("execute",{
#testthat::skip_on_cran()
#cfg_file = system.file("extdata/workflows/config_metadata_ncml.json", package = "geoflow")
#execution
#EXEC <- geoflow::executeWorkflow(cfg_file, dir = ".")
#expect_true(dir.exists(EXEC))
#expect_true(file.exists(file.path(EXEC, "job.json")))
#expect_true(file.exists(file.path(EXEC, "job-logs.txt")))
})

0 comments on commit ec5eb1f

Please sign in to comment.