diff --git a/aip/classic/merger.py b/aip/classic/merger.py index 41068ae..ad535bb 100644 --- a/aip/classic/merger.py +++ b/aip/classic/merger.py @@ -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 diff --git a/tests/classic/test_merger.py b/tests/classic/test_merger.py index 337b11d..dfec66f 100644 --- a/tests/classic/test_merger.py +++ b/tests/classic/test_merger.py @@ -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) @@ -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([])