def test_record_parsing(self): """Test parsing of sample file.""" from harvestingkit.bibrecord import BibRecordPackage bibrecs = BibRecordPackage(self.inspire_demo_data_path_oai) bibrecs.parse() self.assertEqual(len(bibrecs.get_records()), 5)
def test_is_published(self): """Test if published is correct.""" from harvestingkit.bibrecord import BibRecordPackage from harvestingkit.inspire_cds_package.from_inspire import Inspire2CDS bibrecs = BibRecordPackage(self.inspire_demo_data_path_oai) bibrecs.parse() non_published_record = Inspire2CDS(bibrecs.get_records()[0]) self.assertTrue(non_published_record.is_published())
def test_non_oai_conversion(self): """Test conversion of non-OAI-PMH input MARCXML.""" from harvestingkit.bibrecord import BibRecordPackage from harvestingkit.inspire_cds_package.from_inspire import Inspire2CDS bibrecs = BibRecordPackage(self.inspire_demo_data_path) bibrecs.parse() xml = Inspire2CDS.convert_all(bibrecs.get_records()) self.assertEqual(xml.count("</record>"), 3) self.assertEqual(xml.count('<controlfield tag="003">SzGeCERN</controlfield>'), 3)
def test_multiple_conversions(self): """Test conversion of multiple records.""" from harvestingkit.bibrecord import BibRecordPackage from harvestingkit.inspire_cds_package.from_inspire import Inspire2CDS bibrecs = BibRecordPackage(self.inspire_demo_data_path_oai) bibrecs.parse() xml = Inspire2CDS.convert_all(bibrecs.get_records()) self.assertEqual(xml.count("</record>"), 5) self.assertEqual(xml.count('<controlfield tag="003">SzGeCERN</controlfield>'), 5)
def setUp(self): """Load demo data.""" from harvestingkit.bibrecord import BibRecordPackage from harvestingkit.inspire_cds_package.from_inspire import Inspire2CDS self.inspire_demo_data_path = pkg_resources.resource_filename( 'harvestingkit.tests', os.path.join('data', 'sample_inspire.xml')) bibrecs = BibRecordPackage(self.inspire_demo_data_path) bibrecs.parse() self.parsed_record = bibrecs.get_records()[0] self.package = Inspire2CDS(self.parsed_record) self.recid = self.package.get_recid() self.converted_record = self.package.get_record()
def setUp(self): """Load demo data.""" from harvestingkit.bibrecord import BibRecordPackage from harvestingkit.inspire_cds_package.from_inspire import Inspire2CDS self.inspire_demo_data_path = pkg_resources.resource_filename( 'harvestingkit.tests', os.path.join('data', 'sample_inspire_oai.xml') ) bibrecs = BibRecordPackage(self.inspire_demo_data_path) bibrecs.parse() parsed_record = bibrecs.get_records()[1] self.package = Inspire2CDS(parsed_record) self.recid = self.package.get_recid() self.converted_record = self.package.get_record()