예제 #1
0
 def test_fetch_metadata_from_dois_no_paper(self, monkeypatch):
     """
     If no paper created, expect None
     """
     monkeypatch.setattr(Paper, 'create_by_doi', lambda x: None)
     monkeypatch.setattr(CrossRef, 'fetch_batch', lambda x: [None])
     o = OrcidPaperSource()
     papers = list(o.fetch_metadata_from_dois('spam', 'ham', ['any_doi']))
     assert len(papers) == 1
     assert papers[0] is None
예제 #2
0
 def test_fetch_metadata_from_dois(self, researcher_lesot):
     """
     Fetch metadata from doi
     """
     dois = ['10.1016/j.ijar.2017.06.011']
     o = OrcidPaperSource()
     ref_name = (researcher_lesot.name.first, researcher_lesot.name.last)
     papers = list(
         o.fetch_metadata_from_dois(ref_name, researcher_lesot.orcid, dois))
     assert len(papers) == 1
     p = papers[0]
     # Lesot is now a researcher of the paper
     assert p.authors_list[1]['researcher_id'] == researcher_lesot.pk
     # There must be a second OaiRecord
     p.cache_oairecords()  # Cache is not up to date
     assert len(p.oairecords) == 2