Exemplo n.º 1
0
 def test_create_dc_dmdsec_no_dc_no_transfers_dir(self):
     """It should not fail if no transfers directory exists."""
     badsipuuid = 'dnednedn-5bd2-4249-84a1-2f00f725b981'
     state = create_mets_v2.MetsState()
     dmdsec_elem = create_mets_v2.createDublincoreDMDSecFromDBData(Job("stub", "stub", []), self.siptypeuuid, badsipuuid, THIS_DIR, state)
     # Expect no element
     assert dmdsec_elem is None
Exemplo n.º 2
0
 def test_create_dc_dmdsec_no_dc_no_transfers(self):
     """It should not fail if no dublincore.xml exists from transfers."""
     badsipuuid = 'dnednedn-5bd2-4249-84a1-2f00f725b981'
     empty_transfers_sip = os.path.join(THIS_DIR, 'fixtures', 'emptysip')
     # Make sure directory is empty
     try:
         os.remove(os.path.join(empty_transfers_sip, 'objects', 'metadata', 'transfers', '.gitignore'))
     except OSError:
         pass
     dmdsec_elem = create_mets_v2.createDublincoreDMDSecFromDBData(Job("stub", "stub", []), self.siptypeuuid, badsipuuid, empty_transfers_sip)
     assert dmdsec_elem is None
     # Reset directory state
     with open(os.path.join(empty_transfers_sip, 'objects', 'metadata', 'transfers', '.gitignore'), 'w'):
         pass
Exemplo n.º 3
0
 def test_create_dc_dmdsec_dc_exists(self):
     """It should create a dmdSec if DC information exists."""
     # Generate dmdSec if DC exists
     dmdsec_elem, dmdid = create_mets_v2.createDublincoreDMDSecFromDBData(Job("stub", "stub", []), self.siptypeuuid, self.sipuuid, THIS_DIR)
     # Verify created correctly
     assert dmdsec_elem is not None
     assert dmdsec_elem.tag == '{http://www.loc.gov/METS/}dmdSec'
     assert dmdsec_elem.attrib['ID'] == dmdid
     assert len(dmdsec_elem) == 1
     mdwrap = dmdsec_elem[0]
     assert mdwrap.tag == '{http://www.loc.gov/METS/}mdWrap'
     assert mdwrap.attrib['MDTYPE'] == 'DC'
     assert len(mdwrap) == 1
     xmldata = mdwrap[0]
     assert xmldata.tag == '{http://www.loc.gov/METS/}xmlData'
     assert len(xmldata) == 1
     assert xmldata[0].tag == '{http://purl.org/dc/terms/}dublincore'
Exemplo n.º 4
0
 def test_create_dc_dmdsec_no_dc_no_transfers(self):
     """It should not fail if no dublincore.xml exists from transfers."""
     badsipuuid = "dnednedn-5bd2-4249-84a1-2f00f725b981"
     sip_dir = Path(tempfile.mkdtemp()) / "emptysip"
     try:
         shutil.copytree(
             os.path.join(THIS_DIR, "fixtures", "emptysip"), str(sip_dir)
         )
         # Make sure directory is empty
         (sip_dir / "objects/metadata/transfers/.gitignore").unlink()
         state = create_mets_v2.MetsState()
         dmdsec_elem = create_mets_v2.createDublincoreDMDSecFromDBData(
             Job("stub", "stub", []),
             self.siptypeuuid,
             badsipuuid,
             str(sip_dir),
             state,
         )
         assert dmdsec_elem is None
     finally:
         shutil.rmtree(str(sip_dir.parent))