generated from usnistgov/opensource-repo
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
msd3: add responsibleOrganization by default; use NSD to get org info
- Loading branch information
Showing
4 changed files
with
76 additions
and
11 deletions.
There are no files selected for viewing
Submodule metadata
updated
3 files
+1 −0 | docker/pymongo/cacerts/README.md | |
+14 −2 | model/examples/ceramicsportal.json | |
+17 −1 | model/nerdm-pub-schema.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import os, json, pdb, logging, tempfile, pathlib | ||
from typing import Mapping | ||
import unittest as test | ||
|
||
from nistoar.midas.dbio import inmem, base, AlreadyExists, InvalidUpdate, ObjectNotFound, PartNotAccessible | ||
|
@@ -57,6 +58,11 @@ def setUp(self): | |
# "type": "fsbased", | ||
# "store_dir": os.path.join(tmpdir.name) | ||
"type": "inmem", | ||
}, | ||
"default_responsible_org": { | ||
"@type": "org:Organization", | ||
"@id": mds3.NIST_ROR, | ||
"title": "NIST" | ||
} | ||
} | ||
self.dbfact = inmem.InMemoryDBClientFactory({}, { "nextnum": { "mdsy": 2 }}) | ||
|
@@ -144,10 +150,16 @@ def test_create_record_withdata(self): | |
self.assertEqual(prec.data['@id'], "ark:/88434/mdsy-0004") | ||
self.assertEqual(prec.data['nonfile_count'], 1) | ||
self.assertNotIn('contactPoint', prec.data) | ||
self.assertTrue(isinstance(prec.data.get('responsibleOrganization'), list)) | ||
self.assertEqual(prec.data['responsibleOrganization'][0], 'NIST') | ||
nerd = self.svc._store.open(prec.id) | ||
resmd = nerd.get_res_data() | ||
links = nerd.nonfiles | ||
self.assertEqual(len(links), 1) | ||
self.assertEqual(links.get(0)['accessURL'], prec.meta['softwareLink']) | ||
self.assertTrue(isinstance(resmd.get('responsibleOrganization'), list)) | ||
self.assertEqual(len(resmd['responsibleOrganization']), 1) | ||
self.assertEqual(resmd['responsibleOrganization'][0]['title'], 'NIST') | ||
|
||
|
||
# inject some identity info into service and try again | ||
|
@@ -166,7 +178,8 @@ def test_create_record_withdata(self): | |
self.assertIn('contactPoint', prec.data) | ||
self.assertEqual(prec.data['contactPoint'], {"@type": "vcard:Contact", "fn": "Gurn Cranston", | ||
"hasEmail": "mailto:[email protected]"}) | ||
|
||
self.assertTrue(isinstance(prec.data.get('responsibleOrganization'), list)) | ||
self.assertEqual(prec.data['responsibleOrganization'][0], 'NIST') | ||
|
||
def test_moderate_restype(self): | ||
self.create_service() | ||
|
@@ -861,14 +874,15 @@ def test_clear_data(self): | |
pdrid = "ark:/88434/%s-%s" % tuple(prec.id.split(":")) | ||
nerd = self.svc.get_nerdm_data(prec.id) | ||
self.assertEqual(set(nerd.keys()), | ||
{"_schema", "@id", "doi", "_extensionSchemas", "@context", "@type"}) | ||
{"_schema", "@id", "doi", "_extensionSchemas", "@context", "@type", | ||
"responsibleOrganization"}) | ||
|
||
nerd = self.svc.update_data(prec.id, | ||
{"landingPage": "https://example.com", | ||
"contactPoint": { "fn": "Gurn Cranston", "hasEmail": "mailto:[email protected]"}}) | ||
self.assertEqual(set(nerd.keys()), | ||
{"_schema", "@id", "doi", "_extensionSchemas", "@context", "@type", | ||
"contactPoint", "landingPage"}) | ||
"contactPoint", "landingPage", "responsibleOrganization"}) | ||
self.assertEqual(set(nerd["contactPoint"].keys()), {"@type", "fn", "hasEmail"}) | ||
|
||
with self.assertRaises(PartNotAccessible): | ||
|
@@ -878,20 +892,21 @@ def test_clear_data(self): | |
nerd = self.svc.get_nerdm_data(prec.id) | ||
self.assertEqual(set(nerd.keys()), | ||
{"_schema", "@id", "doi", "_extensionSchemas", "@context", "@type", | ||
"contactPoint", "landingPage"}) | ||
"contactPoint", "landingPage", "responsibleOrganization"}) | ||
self.assertEqual(set(nerd["contactPoint"].keys()), {"@type", "fn", "hasEmail"}) | ||
|
||
self.assertIs(self.svc.clear_data(prec.id, "landingPage"), True) | ||
nerd = self.svc.get_nerdm_data(prec.id) | ||
self.assertEqual(set(nerd.keys()), | ||
{"_schema", "@id", "doi", "_extensionSchemas", "@context", "@type", | ||
"contactPoint"}) | ||
"contactPoint", "responsibleOrganization"}) | ||
self.assertIs(self.svc.clear_data(prec.id, "references"), False) | ||
|
||
self.assertIs(self.svc.clear_data(prec.id), True) | ||
nerd = self.svc.get_nerdm_data(prec.id) | ||
self.assertEqual(set(nerd.keys()), | ||
{"_schema", "@id", "doi", "_extensionSchemas", "@context", "@type"}) | ||
{"_schema", "@id", "doi", "_extensionSchemas", "@context", "@type", | ||
"responsibleOrganization"}) | ||
|
||
|
||
def test_update(self): | ||
|