def test_get_pages_wrong_letter(self):
     item = {
         'page': '583b-584'
     }
     crossref_processor = CrossrefProcessing(orcid_index=None, doi_csv=None, publishers_filepath=PUBLISHERS_MAPPING)
     pages = crossref_processor.get_pages(item)
     self.assertEqual(pages, '583-584')
 def test_get_agents_strings_list(self):
     authors_list = [
         {
             'given': 'Myung-Hee',
             'family': 'Kim',
             'affiliation': []
         },
         {
             'given': 'Jin-Seon',
             'family': 'Seo',
             'affiliation': []
         },
         {
             'given': 'Mi-Kyeong',
             'family': 'Choi',
             'affiliation': []
         },
         {
             'given': 'Eun-Young',
             'family': 'Kim',
             'affiliation': []
         }
     ]
     crossref_processor = CrossrefProcessing(IOD, WANTED_DOIS)
     authors_strings_list = crossref_processor.get_agents_strings_list('10.9799/ksfan.2012.25.1.105', authors_list)
     expected_authors_list = ['Kim, Myung-Hee', 'Seo, Jin-Seon', 'Choi, Mi-Kyeong [orcid:0000-0002-6227-4053]', 'Kim, Eun-Young']
     self.assertEqual(authors_strings_list, expected_authors_list)
 def test_get_pages_non_roman_letters(self):
     item = {
         'page': 'kj-hh'
     }
     crossref_processor = CrossrefProcessing(orcid_index=None, doi_csv=None, publishers_filepath=PUBLISHERS_MAPPING)
     pages = crossref_processor.get_pages(item)
     self.assertEqual(pages, '')
 def test_get_venue_name(self):
     item = {
         'container-title': ['Cerebrospinal Fluid [Working Title]'],
     }
     row = {'id': '', 'title': '', 'author': '', 'pub_date': '', 'venue': '', 'volume': '', 'issue': '', 'page': '', 'type': 'journal article', 'publisher': '', 'editor': ''}
     crossref_processor = CrossrefProcessing(orcid_index=None, doi_csv=None, publishers_filepath=PUBLISHERS_MAPPING)
     venue_name = crossref_processor.get_venue_name(item, row)
     self.assertEqual(venue_name, 'Cerebrospinal Fluid [Working Title]')
 def test_get_venue_name_with_ISSN(self):
     item = {
         'container-title': ["troitel'stvo: nauka i obrazovanie [Construction: Science and Education]"],
         'ISSN': '2305-5502'
     }
     row = {'id': '', 'title': '', 'author': '', 'pub_date': '', 'venue': '', 'volume': '', 'issue': '', 'page': '', 'type': 'journal article', 'publisher': '', 'editor': ''}
     crossref_processor = CrossrefProcessing(orcid_index=None, doi_csv=None, publishers_filepath=PUBLISHERS_MAPPING)
     venue_name = crossref_processor.get_venue_name(item, row)
     self.assertEqual(venue_name, "troitel'stvo: nauka i obrazovanie [Construction: Science and Education] [issn:2305-5502]")
 def test_id_worker(self):
     field_issn = 'ISSN 1050-124X'
     field_isbn = ['978-1-56619-909-4']
     issn_list = list()
     isbn_list = list()
     CrossrefProcessing.id_worker(field_issn, issn_list, CrossrefProcessing.issn_worker)
     CrossrefProcessing.id_worker(field_isbn, isbn_list, CrossrefProcessing.isbn_worker)
     expected_issn_list = ['issn:1050-124X']
     expected_isbn_list = ['isbn:9781566199094']
     self.assertEqual((issn_list, isbn_list), (expected_issn_list, expected_isbn_list))
 def test_get_publisher_name_no_member(self):
     # The item has no member, but the DOI prefix is the publishers' mapping
     item = {
         'publisher': 'American Fisheries Society',
         'DOI': '10.47886/9789251092637.ch7',
         'prefix': '10.47886'
     }
     doi = '10.47886/9789251092637.ch7'
     crossref_processor = CrossrefProcessing(orcid_index=None, doi_csv=None, publishers_filepath=PUBLISHERS_MAPPING)
     publisher_name = crossref_processor.get_publisher_name(doi, item)
     self.assertEqual(publisher_name, 'American Fisheries Society [crossref:460]')
 def test_csv_creator(self):
     crossref_processor = CrossrefProcessing(orcid_index=IOD, doi_csv=WANTED_DOIS, publishers_filepath=None)
     data = load_json(DATA, None)
     csv_created = crossref_processor.csv_creator(data)
     expected_output = [
         {'id': 'doi:10.47886/9789251092637.ch7', 'title': 'Freshwater, Fish and the Future: Proceedings of the Global Cross-Sectoral Conference', 'author': '', 'pub_date': '2016', 'venue': 'Freshwater, Fish and the Future: Proceedings of the Global Cross-Sectoral Conference', 'volume': '', 'issue': '', 'page': '', 'type': 'book chapter', 'publisher': 'American Fisheries Society [crossref:460]', 'editor': 'Lymer, David; Food and Agriculture Organization of the United Nations Fisheries and Aquaculture Department Viale delle Terme di Caracalla Rome 00153 Italy; Marttin, Felix; Marmulla, Gerd; Bartley, Devin M.'},
         {'id': 'doi:10.9799/ksfan.2012.25.1.069', 'title': 'Nonthermal Sterilization and Shelf-life Extension of Seafood Products by Intense Pulsed Light Treatment', 'author': 'Cheigh, Chan-Ick; Mun, Ji-Hye; Chung, Myong-Soo', 'pub_date': '2012-3-31', 'venue': 'The Korean Journal of Food And Nutrition [issn:1225-4339]', 'volume': '25', 'issue': '1', 'page': '69-76', 'type': 'journal article', 'publisher': 'The Korean Society of Food and Nutrition [crossref:4768]', 'editor': ''}, 
         {'id': 'doi:10.9799/ksfan.2012.25.1.105', 'title': 'A Study on Dietary Habit and Eating Snack Behaviors of Middle School Students with Different Obesity Indexes in Chungnam Area', 'author': 'Kim, Myung-Hee; Seo, Jin-Seon; Choi, Mi-Kyeong [orcid:0000-0002-6227-4053]; Kim, Eun-Young', 'pub_date': '2012-3-31', 'venue': 'The Korean Journal of Food And Nutrition [issn:1225-4339]', 'volume': '25', 'issue': '1', 'page': '105-115', 'type': 'journal article', 'publisher': 'The Korean Society of Food and Nutrition [crossref:4768]', 'editor': ''}, 
         {'id': 'doi:10.9799/ksfan.2012.25.1.123', 'title': 'The Protective Effects of Chrysanthemum cornarium L. var. spatiosum Extract on HIT-T15 Pancreatic β-Cells against Alloxan-induced Oxidative Stress', 'author': 'Kim, In-Hye; Cho, Kang-Jin; Ko, Jeong-Sook; Kim, Jae-Hyun; Om, Ae-Son', 'pub_date': '2012-3-31', 'venue': 'The Korean Journal of Food And Nutrition [issn:1225-4339]', 'volume': '25', 'issue': '1', 'page': '123-131', 'type': 'journal article', 'publisher': 'The Korean Society of Food and Nutrition [crossref:4768]', 'editor': ''}
     ]
     self.assertEqual(csv_created, expected_output)
 def test_report_series_br_id(self):
     crossref_processor = CrossrefProcessing(orcid_index=IOD, doi_csv=WANTED_DOIS, publishers_filepath=None)
     item = {'items': [{
         'DOI': '10.1007/978-3-030-00668-6_8',
         'container-title': [],
         'ISSN': '2305-5502',
         'type': 'report-series'
     }]}
     crossref_processor = CrossrefProcessing(orcid_index=None, doi_csv=None, publishers_filepath=PUBLISHERS_MAPPING)
     output = crossref_processor.csv_creator(data=item)
     expected_output = [{'id': 'doi:10.1007/978-3-030-00668-6_8 issn:2305-5502', 'title': '', 'author': '', 'pub_date': '', 'venue': '', 'volume': '', 'issue': '', 'page': '', 'type': 'report series', 'publisher': '', 'editor': ''}]
     self.assertEqual(output, expected_output)
 def test_get_agents_strings_list_overlapping_surnames(self):
     # The surname of one author is included in the surname of another.
     authors_list = [
         {
             "given": "Puvaneswari",
             "family": "Paravamsivam",
             "sequence": "first",
             "affiliation": []
         },
         {
             "given": "Chua Kek",
             "family": "Heng",
             "sequence": "additional",
             "affiliation": []
         },
         {
             "given": "Sri Nurestri Abdul",
             "family": "Malek",
             "sequence": "additional",
             "affiliation": []
         },
         {
             "given": "Vikineswary",
             "family": "Sabaratnam",
             "sequence": "additional",
             "affiliation": []
         },
         {
             "given": "Ravishankar Ram",
             "family": "M",
             "sequence": "additional",
             "affiliation": []
         },
         {
             "given": "Umah Rani",
             "family": "Kuppusamy",
             "sequence": "additional",
             "affiliation": []
         }
     ]
     crossref_processor = CrossrefProcessing(None, None)
     csv_manager = CSVManager()
     csv_manager.data = {'10.9799/ksfan.2012.25.1.105': {'Malek, Sri Nurestri Abdul [orcid:0000-0001-6278-8559]'}}
     crossref_processor.orcid_index = csv_manager
     authors_strings_list = crossref_processor.get_agents_strings_list('10.9799/ksfan.2012.25.1.105', authors_list)
     expected_authors_list = ['Paravamsivam, Puvaneswari', 'Heng, Chua Kek', 'Malek, Sri Nurestri Abdul [orcid:0000-0001-6278-8559]', 'Sabaratnam, Vikineswary', 'M, Ravishankar Ram', 'Kuppusamy, Umah Rani']
     self.assertEqual(authors_strings_list, expected_authors_list)
 def test_get_agents_strings_list_homonyms(self):
     # Two authors have the same family name and the same given name
     authors_list = [
         {
             'given': 'Mi-Kyeong',
             'family': 'Choi',
             'affiliation': []
         },
         {
             'given': 'Mi-Kyeong',
             'family': 'Choi',
             'affiliation': []
         }
     ]
     crossref_processor = CrossrefProcessing(IOD, WANTED_DOIS)
     authors_strings_list = crossref_processor.get_agents_strings_list('10.9799/ksfan.2012.25.1.105', authors_list)
     expected_authors_list = ['Choi, Mi-Kyeong', 'Choi, Mi-Kyeong']
     self.assertEqual(authors_strings_list, expected_authors_list)
 def test_load_publishers_mapping(self):
     output = CrossrefProcessing.load_publishers_mapping(publishers_filepath=PUBLISHERS_MAPPING)
     expected_output = {
         '1': {'name': 'Annals of Family Medicine', 'prefixes': {'10.1370'}},
         '2': {'name': 'American Association of Petroleum Geologists AAPG/Datapages', 'prefixes': {'10.15530', '10.1306'}},
         '3': {'name': 'American Association of Physics Teachers (AAPT)','prefixes': {'10.1119'}},
         '6': {'name': 'American College of Medical Physics (ACMP)','prefixes': {'10.1120'}},
         '9': {'name': 'Allen Press', 'prefixes': {'10.1043'}},
         '10': {'name': 'American Medical Association (AMA)', 'prefixes': {'10.1001'}},
         '11': {'name': 'American Economic Association', 'prefixes': {'10.1257'}},
         '460': {'name': 'American Fisheries Society', 'prefixes': {'10.1577', '10.47886'}}
     }
     self.assertEqual(output, expected_output)
 def test_orcid_finder(self):
     crossref_processor = CrossrefProcessing(IOD, WANTED_DOIS)
     orcid_found = crossref_processor.orcid_finder('10.9799/ksfan.2012.25.1.105')
     expected_output = {'0000-0002-6227-4053': 'choi, mi-kyeong'}
     self.assertEqual(orcid_found, expected_output)
 def test_isbn_worker(self):
     input = '978-1-56619-909-4'
     output = list()
     CrossrefProcessing.isbn_worker(input, output)
     expected_output = ['isbn:9781566199094']
     self.assertEqual(output, expected_output)
 def test_issn_worker(self):
     input = 'ISSN 1050-124X'
     output = list()
     CrossrefProcessing.issn_worker(input, output)
     expected_output = ['issn:1050-124X']
     self.assertEqual(output, expected_output)