def test_taxon_rank_abbr(self): dwc = darwincore.make_simple_darwin_record_set() dwc.create_simple_darwin_record() indexer = darwincore.SimpleDarwinRecordIndexer(dwc.simple_darwin_record) self.assertEqual(indexer._get_taxon_rank_abbr(), '') dwc.simple_darwin_record.taxon_rank = 'variety' self.assertEqual(indexer._get_taxon_rank_abbr(), 'var.') dwc.simple_darwin_record.taxon_rank = 'subspecies' self.assertEqual(indexer._get_taxon_rank_abbr(), 'subsp.')
def __init__(self, record_type, field_data, parent_mods=None): self.dataSeparator = u'||' self._parent_mods = parent_mods #dict for keeping track of which fields we've cleared out the parent # info for. So we can have multiple columns in the spreadsheet w/ the same field. self._cleared_fields = {} self._record_type = record_type if record_type == 'dwc': self._xml_obj = darwincore.make_simple_darwin_record_set() self._xml_obj.create_simple_darwin_record() else: if parent_mods: self._xml_obj = parent_mods else: self._xml_obj = mods.make_mods() for field in field_data: self.add_data(field['xml_path'], field['data'])
def __init__(self, record_type, field_data, parent_mods=None): self.dataSeparator = u'||' self._parent_mods = parent_mods #dict for keeping track of which fields we've cleared out the parent # info for. So we can have multiple columns in the spreadsheet w/ the same field. self._cleared_fields = {} self._record_type = record_type if record_type == 'dwc': self._xml_obj = darwincore.make_simple_darwin_record_set() self._xml_obj.create_simple_darwin_record() else: if parent_mods: self._xml_obj = parent_mods else: self._xml_obj = mods.make_mods() for field in field_data: self.add_data(field['xml_path'], field['data'])
def test_create(self): mets = make_mets() #mods mods_section = make_mods() mods_section.title = 'sample' mets.create_mods() mets.mods = mods_section #dwc dwc_section = make_simple_darwin_record_set() dwc_section.create_simple_darwin_record() dwc_section.simple_darwin_record.catalog_number = 'catalog number' mets.create_dwc() mets.dwc = dwc_section #ir mets.create_ir() mets.ir.filename = 'sample.txt' #filesec -> filegrp mets.create_filesec() fg = FileGrp() fg.id = u'GID1' fg.use = u'image-tiff' fi = File() fi.admid = u'TMD1' fi.groupid = u'GRP1' fi.id = u'FID1' fi.MIMETYPE = u'image/tiff' fi.loctype = u'URL' fi.href = u'/the/path.tif' fg.file.append( fi ) mets.filesec.filegrp.append( fg ) #structMap mets.create_structmap() # not used but required for valid mets #serialize created_string = mets.serialize( pretty=True ) #load loaded = load_xmlobject_from_string(created_string, BDRMets) #test self.assertEqual(loaded.mods.title, 'sample') self.assertEqual(loaded.dwc.simple_darwin_record.catalog_number, 'catalog number') self.assertEqual(loaded.ir.filename, 'sample.txt') self.assertEqual( type(loaded.structmap), StructMap ) self.assertEqual( loaded.filesec.filegrp[0].file[0].node.items(), [('ADMID', 'TMD1'), ('GROUPID', 'GRP1'), ('ID', 'FID1')] )
def setUp(self): self.dwc = darwincore.make_simple_darwin_record_set()