Skip to content
Snippets Groups Projects
Commit 1baf48cc authored by Mike Lynch's avatar Mike Lynch
Browse files

Added test for a bug which was making the converter die when it got a

funding body which was an empty object -- this was killing data publications
because ReDBox puts them in when the user hasn't selected one. Fixed the
bug.
parent cdc6ce5b
No related merge requests found
...@@ -388,7 +388,8 @@ function make_funders(datapub, prefix) { ...@@ -388,7 +388,8 @@ function make_funders(datapub, prefix) {
var f = []; var f = [];
return FUNDING_FIELDS.map((field) => { return FUNDING_FIELDS.map((field) => {
if( datapub[field] ) { if( datapub[field] ) {
return datapub[field].map((forg) => { const funders = datapub[field].filter((forg) => forg['dc_identifier']);
return funders.map((forg) => {
const id = prefix + forg['dc_identifier'][0]; const id = prefix + forg['dc_identifier'][0];
return { return {
'@id': id, '@id': id,
......
...@@ -103,6 +103,33 @@ var mdp, dp, cj, cjds; ...@@ -103,6 +103,33 @@ var mdp, dp, cj, cjds;
// range of different test datapubs which didn't have all of // range of different test datapubs which didn't have all of
// the values // the values
describe("Try to load a janky DataPub with empty fields", () => {
it("Loads without throwing an error", async () => {
mdp = await fs.readJson('./test_data/janky_datapub.json');
dp = mdp['metadata'];
cj = await catalog.datapub2catalog({
'id': DATASET_ID,
'datapub': dp,
'organisation': ORG,
'owner': OWNER,
'approver': APPROVER,
'prefixes': IRI_PREFIXES
});
expect(cj).to.be.an('object');
expect(cj).to.have.property('@graph');
expect(cj).to.have.property('@context');
});
});
describe("Convert a ReDBox 2.0 DataPub to CATALOG.json", () => { describe("Convert a ReDBox 2.0 DataPub to CATALOG.json", () => {
before(async () => { before(async () => {
......
{
"metaMetadata" : {
"brandId" : "5bf2a80aa4d6ac000642692b",
"createdBy" : "aHR0cHM6Ly9yYXBpZC50ZXN0LmFhZi5lZHUuYXUhaHR0cDovL2xvY2FsaG9zdDoxNTAwL2RlZmF1bHQvcmRtcC8hYmxxbkxJOGx1ZmxSSkRTZ1dURm5hbzdhenprPQ==",
"type" : "dataPublication",
"form" : "dataPublication-1.0-published",
"attachmentFields" : null,
"lastSavedBy" : "aHR0cHM6Ly9yYXBpZC50ZXN0LmFhZi5lZHUuYXUhaHR0cDovL2xvY2FsaG9zdDoxNTAwL2RlZmF1bHQvcmRtcC8hYmxxbkxJOGx1ZmxSSkRTZ1dURm5hbzdhenprPQ==",
"lastSaveDate" : "2018-11-27T14:25:17+10:00"
},
"authorization" : {
"view" : [
"aHR0cHM6Ly9yYXBpZC50ZXN0LmFhZi5lZHUuYXUhaHR0cDovL2xvY2FsaG9zdDoxNTAwL2RlZmF1bHQvcmRtcC8hYmxxbkxJOGx1ZmxSSkRTZ1dURm5hbzdhenprPQ=="
],
"edit" : [
"aHR0cHM6Ly9yYXBpZC50ZXN0LmFhZi5lZHUuYXUhaHR0cDovL2xvY2FsaG9zdDoxNTAwL2RlZmF1bHQvcmRtcC8hYmxxbkxJOGx1ZmxSSkRTZ1dURm5hbzdhenprPQ=="
],
"viewRoles" : [
"Admin",
"Librarians"
],
"editRoles" : [
"Admin",
"Librarians"
]
},
"metadata" : {
"parameterRetriever" : "",
"dataRecordGetter" : "",
"" : {},
"dataRecord" : {
"oid" : "5eb3fc7d1ec7979ccc7e3367d02c2dac",
"title" : "Photographs of the Clyde Gorge"
},
"title" : "Photographs of the Clyde Gorge",
"description" : "Photographs of the Clyde Gorge",
"dc:subject_anzsrc:toa_rdf:resource" : "dataset",
"finalKeywords" : [
"lansdscape",
"photography"
],
"foaf:fundedBy_foaf:Agent" : [
{}
],
"foaf:fundedBy_vivo:Grant" : [
{}
],
"dc:subject_anzsrc:for" : [
{
"name" : "1905 - VISUAL ARTS AND CRAFTS",
"label" : "VISUAL ARTS AND CRAFTS",
"notation" : "1905",
"geneaology" : [
"19"
]
}
],
"dc:subject_anzsrc:seo" : [],
"startDate" : "",
"endDate" : "",
"timePeriod" : "",
"geolocations" : [
""
],
"geospatial" : {},
"accessRightsToggle" : "",
"dataLocations" : [
{
"type" : "attachment",
"location" : "5eb3fc7d1ec7979ccc7e3367d02c2dac/attach/e0d51800609d5447c6ce717a8a9af4a3",
"mimeType" : "image/jpeg",
"name" : "clyde_conv1_7x7_s2.jpg",
"fileId" : "e0d51800609d5447c6ce717a8a9af4a3",
"uploadUrl" : "http://localhost:1500/default/rdmp/record/5eb3fc7d1ec7979ccc7e3367d02c2dac/attach/e0d51800609d5447c6ce717a8a9af4a3",
"selected" : true
},
{
"type" : "attachment",
"location" : "5eb3fc7d1ec7979ccc7e3367d02c2dac/attach/14f38f6dc71ed26a9341830d65137c30",
"mimeType" : "image/jpeg",
"name" : "clyde_big.jpg",
"fileId" : "14f38f6dc71ed26a9341830d65137c30",
"uploadUrl" : "http://localhost:1500/default/rdmp/record/5eb3fc7d1ec7979ccc7e3367d02c2dac/attach/14f38f6dc71ed26a9341830d65137c30",
"selected" : true
},
{
"type" : "attachment",
"location" : "5eb3fc7d1ec7979ccc7e3367d02c2dac/attach/868066e4ee3e22f93255938ef5b6cb32",
"mimeType" : "image/jpeg",
"name" : "clyde_conv2_3x3_reduce.jpg",
"fileId" : "868066e4ee3e22f93255938ef5b6cb32",
"uploadUrl" : "http://localhost:1500/default/rdmp/record/5eb3fc7d1ec7979ccc7e3367d02c2dac/attach/868066e4ee3e22f93255938ef5b6cb32",
"selected" : true
}
],
"dataLicensingAccess_manager" : "Michael Lynch",
"dc:accessRights" : "Open",
"accessRights_url" : "",
"related_publications" : [
{
"related_title" : "",
"related_url" : "",
"related_notes" : ""
}
],
"related_websites" : [
{
"related_title" : "",
"related_url" : "",
"related_notes" : ""
}
],
"related_metadata" : [
{
"related_title" : "",
"related_url" : "",
"related_notes" : ""
}
],
"related_data" : [
{
"related_title" : "",
"related_url" : "",
"related_notes" : ""
}
],
"related_services" : [
{
"related_title" : "",
"related_url" : "",
"related_notes" : ""
}
],
"license_identifier" : "",
"license_notes" : "",
"license_other_url" : "",
"license_statement" : "Copyright ReDBox Research Data 2018",
"license_statement_url" : "",
"citation_doi" : "",
"requestIdentifier" : [],
"citation_title" : "Title",
"creators" : [
{
"text_full_name" : "Michael Lynch",
"email" : "Michael.Lynch@uts.edu.au",
"role" : "Chief Investigator",
"username" : "",
"orcid" : "",
"family_name" : "Lynch",
"given_name" : "Michael"
},
{
"text_full_name" : "Michael Lynch",
"email" : "Michael.Lynch@uts.edu.au",
"role" : "Data manager",
"username" : "aHR0cHM6Ly9yYXBpZC50ZXN0LmFhZi5lZHUuYXUhaHR0cDovL2xvY2FsaG9zdDoxNTAwL2RlZmF1bHQvcmRtcC8hYmxxbkxJOGx1ZmxSSkRTZ1dURm5hbzdhenprPQ==",
"orcid" : "",
"family_name" : "Lynch",
"given_name" : "Michael"
},
{
"text_full_name" : null,
"email" : null,
"role" : "Contributors",
"username" : "",
"orcid" : "",
"family_name" : "",
"given_name" : ""
},
{
"text_full_name" : null,
"email" : null,
"role" : "Supervisor",
"username" : "",
"orcid" : "",
"family_name" : "",
"given_name" : ""
}
],
"citation_publisher" : "ReDBox Research Data",
"citation_url" : "http://localhost:8080/public/3a46ff2ec9d7dda3988d43f7d631c5b5",
"citation_publication_date" : "",
"citation_generated" : "Lynch, Michael; Lynch, Michael (Invalid date): Title. ReDBox Research Data. {ID_WILL_BE_HERE}",
"dataowner_name" : "Michael Lynch",
"dataowner_email" : "Michael.Lynch@uts.edu.au",
"contributor_ci" : {
"text_full_name" : "Michael Lynch",
"full_name_honorific" : "Dr Michael Lynch",
"email" : "Michael.Lynch@uts.edu.au",
"given_name" : "Michael",
"family_name" : "Lynch",
"honorific" : "Dr",
"full_name_family_name_first" : "Lynch, Michael",
"username" : "",
"role" : "Chief Investigator"
},
"contributor_data_manager" : {
"text_full_name" : "Michael Lynch",
"full_name_honorific" : "",
"email" : "Michael.Lynch@uts.edu.au",
"given_name" : "Michael",
"family_name" : "Lynch",
"honorific" : "",
"full_name_family_name_first" : "Lynch, Michael",
"username" : "aHR0cHM6Ly9yYXBpZC50ZXN0LmFhZi5lZHUuYXUhaHR0cDovL2xvY2FsaG9zdDoxNTAwL2RlZmF1bHQvcmRtcC8hYmxxbkxJOGx1ZmxSSkRTZ1dURm5hbzdhenprPQ==",
"role" : "Data manager"
},
"contributor_supervisor" : {
"full_name_honorific" : "",
"given_name" : "",
"family_name" : "",
"honorific" : "",
"full_name_family_name_first" : "",
"username" : "",
"role" : "Supervisor"
},
"embargoByDate" : "",
"embargoUntil" : null,
"embargoNote" : "",
"reviewerNote" : "",
"ckanLocation" : ""
},
"workflow" : {
"stage" : "published",
"stageLabel" : "Published"
},
"notification" : {
"state" : "emailed-published",
"log" : {
"reviewing" : [
{
"date" : "2018-11-27T14:24:35"
}
],
"published" : [
{
"date" : "2018-11-27T14:25:19"
}
]
}
},
"previousWorkflow" : {
"stage" : "reviewing",
"stageLabel" : "Reviewing"
},
"redboxOid" : "3a46ff2ec9d7dda3988d43f7d631c5b5",
"packageType" : [
"dataPublication"
],
"date_object_created" : [
"2018-11-27T04:24:34.078Z"
],
"date_object_modified" : [
"2018-11-27T04:25:19.524Z"
]
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment