Skip to content

Commit

Permalink
Merge pull request #275 from aaccomazzi/master
Browse files Browse the repository at this point in the history
Fix bug with metadata with multiple origins
  • Loading branch information
aaccomazzi authored Aug 16, 2022
2 parents 047429d + 7b84ef8 commit 128d535
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aip/classic/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def _getOriginPriority(self,f,field):
origins = f[1]['origin'].split('; ')
o = origins.pop()
for i in origins:
o = i if p.get(i.upper(),0) >= p.get(o1.upper(),0) else o
o = i if p.get(i.upper(),0) >= p.get(o.upper(),0) else o
# if origin not defined, default to 'PUBLISHER'
P = p.get(o.upper(),p.get('PUBLISHER',0))
return P
Expand Down
10 changes: 10 additions & 0 deletions tests/classic/test_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ def test_doiMerger(self):
B1 = {'tempdata':{'origin':'PUBLISHER','type':'general'}}
B2 = {'tempdata':{'origin':'ARXIV','type':'general'}}
B3 = {'tempdata':{'origin':'SIMBAD','type':'general'}}
B4 = {'tempdata':{'origin':'JST; CROSSREF','type':'general'}}

# 2022NatAs...6..331D
B1['doi'] = [ '10.1038/s41550-021-01558-y' ]
B2['doi'] = [ '10.48550/arXiv.2201.05617' ]
B3['doi'] = [ '10.1038/s41550-021-01558-y' ]
B4['doi'] = [ '10.1038/S41550-021-01558-Y' ] # note different case

blocks = [B1,B2]
m = merger.Merger(blocks)
Expand All @@ -107,6 +109,14 @@ def test_doiMerger(self):
expectedResults = { 'doi': [ '10.1038/s41550-021-01558-y', '10.48550/arXiv.2201.05617' ], 'altpublications': [] }
self.assertEqual(results,expectedResults)

blocks = [B4,B2,B1,B3]
m = merger.Merger(blocks)
m.merge()
results = m.block
# the list gets eventually uniqued in solr_adapter
expectedResults = { 'doi': [ '10.1038/S41550-021-01558-Y', '10.1038/s41550-021-01558-y', '10.48550/arXiv.2201.05617' ], 'altpublications': [] }
self.assertEqual(results,expectedResults)


def test_want_datetime(self):
m = merger.Merger([])
Expand Down

0 comments on commit 128d535

Please sign in to comment.