def test_dirty_batches(self): with self.assertRaises(MetadataSourceException): fetch_dois_by_batch(['aunirestauniecb898989'] ) # definitely not a DOI dois = ['10.5281/anuirsetacesecesrbl'] # probably not a DOI results = fetch_dois_by_batch(dois) self.assertTrue(all([item is None for item in results]))
def test_dirty_batches(self): with self.assertRaises(MetadataSourceException): fetch_dois_by_batch(['aunirestauniecb898989' ]) # definitely not a DOI dois = ['10.5281/anuirsetacesecesrbl'] # probably not a DOI results = fetch_dois_by_batch(dois) self.assertTrue(all([item is None for item in results]))
def test_mixed_queries(self): dois = [ '10.1016/0169-5983(88)90079-2', # CrossRef DOI '10.5281/zenodo.12826', # DataCite DOI ] results = fetch_dois_by_batch(dois) self.assertEqual([item['DOI'] for item in results], dois)
def test_batch_queries(self): dois = [ '10.1007/978-3-540-46375-7_2', '10.1007/978-3-540-46375-7_9', '10.2307/2540916', '10.1016/s1169-8330(00)80059-9', '10.1017/s0022112009008003', '10.1051/proc/2011014', '10.1016/0169-5983(88)90079-2', '10.1080/14685240600601061', '10.1103/physreve.79.026303', '10.1103/physreve.66.046307', '10.1103/physrevlett.95.244502', '10.1017/s0022112089002351', '10.1063/1.4738850', '10.1103/physrevlett.87.054501', '10.1080/14685248.2012.711476', '10.1007/978-94-011-4177-2_12', '10.1007/978-1-4615-4697-9_2', '10.1007/978-1-4612-0137-3_7', '10.1007/978-1-4020-6472-2_35'] incremental = list(fetch_dois_incrementally(dois)) self.assertEqual(len(incremental), len(dois)) if settings.DOI_PROXY_SUPPORTS_BATCH: batch = fetch_dois_by_batch(dois) self.assertEqual([item['DOI'] for item in incremental], [item['DOI'] for item in batch])
def test_batch_with_comma(self): """ Having a comma in a DOI should not fail the whole batch, just ignore that particular DOI """ dois = ['10.1016/j.acta,at.2005.01.046','10.1080/14786430410001678217'] batch = fetch_dois_by_batch(dois) fetched_dois = [ item['DOI'] for item in batch if item ] self.assertTrue('10.1080/14786430410001678217' in fetched_dois)
def test_batch_with_comma(self): """ Having a comma in a DOI should not fail the whole batch, just ignore that particular DOI """ dois = [ '10.1016/j.acta,at.2005.01.046', '10.1080/14786430410001678217' ] batch = fetch_dois_by_batch(dois) fetched_dois = [item['DOI'] for item in batch if item] self.assertTrue('10.1080/14786430410001678217' in fetched_dois)
def test_batch_queries(self): dois = [ '10.1007/978-3-540-46375-7_2', '10.1007/978-3-540-46375-7_9', '10.2307/2540916', '10.1016/s1169-8330(00)80059-9', '10.1017/s0022112009008003', '10.1051/proc/2011014', '10.1016/0169-5983(88)90079-2', '10.1080/14685240600601061', '10.1103/physreve.79.026303', '10.1103/physreve.66.046307', '10.1103/physrevlett.95.244502', '10.1017/s0022112089002351', '10.1063/1.4738850', '10.1103/physrevlett.87.054501', '10.1080/14685248.2012.711476', '10.1007/978-94-011-4177-2_12', '10.1007/978-1-4615-4697-9_2', '10.1007/978-1-4612-0137-3_7', '10.1007/978-1-4020-6472-2_35' ] incremental = list(fetch_dois_incrementally(dois)) self.assertEqual(len(incremental), len(dois)) if DOI_PROXY_SUPPORTS_BATCH: batch = fetch_dois_by_batch(dois) self.assertEqual([item['DOI'] for item in incremental], [item['DOI'] for item in batch])