Skip to content

Commit

Permalink
midas3/service follow-on: NERDm replaces needs to be a list
Browse files Browse the repository at this point in the history
  • Loading branch information
RayPlante committed Feb 24, 2023
1 parent 5286b8e commit 9e26362
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 8 additions & 6 deletions python/nistoar/pdr/publish/midas3/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,16 @@ def _copy_oldbag_when_done(self, oldworker, replworker):
with replworker.bagger.lock:
replworker.bagger.ensure_res_metadata()
version = replworker.bagger.sip.nerd.get("version", "1.0.0")
replacesinfo = replworker.bagger.sip.nerd.get("replaces", [])
replacesinfo.append(OrderedDict([
("@id", replworker.bagger.sip.nerd.get("doi", replworker.bagger.sip.nerd.get("@id"))),
("ediid", oldworker.bagger.sip.nerd.get("ediid")),
("issued", replworker.bagger.sip.nerd.get("issued",
replworker.bagger.sip.nerd.get("modified")))
]))
tweak = {
"ediid": replworker.bagger.midasid,
"replaces": OrderedDict([
("@id", replworker.bagger.sip.nerd.get("doi", replworker.bagger.sip.nerd.get("@id"))),
("ediid", oldworker.bagger.sip.nerd.get("ediid")),
("issued", replworker.bagger.sip.nerd.get("issued",
replworker.bagger.sip.nerd.get("modified")))
])
"replaces": replacesinfo
}
replworker.bagger.bagbldr.update_metadata_for("", tweak,
message="setting new EDI-ID for major update")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ def test_copy_oldbag_when_done(self):
self.assertEqual(data.get('ediid'), self.updmidasid)
self.assertEqual(data.get('version'), "1.0.0+ (in edit)")
self.assertIn('replaces', data)
self.assertIn('ediid', data['replaces'])
self.assertEqual(data['replaces'].get("ediid"), oldwrkr.bagger.sip.nerd.get("ediid"))
self.assertGreater(len(data['replaces']), 0)
self.assertIn('ediid', data['replaces'][-1])
self.assertEqual(data['replaces'][-1].get("ediid"), oldwrkr.bagger.sip.nerd.get("ediid"))


def test_update_ds_with_pod_onupdate(self):
Expand Down

0 comments on commit 9e26362

Please sign in to comment.