Esempio n. 1
0
def test_mets_tounicode():
    """Ensure that Mets.tounicode() is working"""
    mets = mm.Mets()
    # Fill with some stuff
    dmd_el = mm.DmdSec(ID='ie1')
    mets.append(dmd_el)
    assert (mets.tounicode().startswith('<mets:mets'))
Esempio n. 2
0
def test_dmdsec_stub_with_invalid_parameter_while_strict():
    print("Testing the generation of a dmdSec element with an attrib key of" +
          " 'IS_HORSEY...' while NOT in default strict mode")
    mm.strict = False
    dmd_el = mm.DmdSec(IS_HORSEY='true')
    assert (len(dmd_el.attrib) == 1)
    # Turn strict back on!
    mm.strict = True
Esempio n. 3
0
def test_mets_write():
    """Ensure that Mets.write() is able to be written to a file."""
    mets = mm.Mets()
    # Fill with some stuff
    dmd_el = mm.DmdSec(ID='ie1')
    mets.append(dmd_el)
    output_files = os.listdir(os.path.join(CURRENT_DIR, 'data', 'output'))
    if len(output_files) != 0:
        for item in output_files:
            os.remove(os.path.join(CURRENT_DIR, 'data', 'output', item))
    mets.write(os.path.join(CURRENT_DIR, 'data', 'output', 'mets.xml'))
Esempio n. 4
0
def test_mets_write_with_utf8_with_macron():
    """check Mets.write() with utf8 with macron in document"""
    print("trying to do the macron thing!")
    print(sys.version)
    mets = mm.Mets()
    # Fill with some stuff
    dmd_el = mm.DmdSec(ID='ie1')
    dmd_el.text = 'māori'
    mets.append(dmd_el)
    output_files = os.listdir(os.path.join(CURRENT_DIR, 'data', 'output'))
    if len(output_files) != 0:
        for item in output_files:
            os.remove(os.path.join(CURRENT_DIR, 'data', 'output', item))
    mets.write(os.path.join(CURRENT_DIR, 'data', 'output', 'mets.xml'),
               encoding='UTF-8')
Esempio n. 5
0
def test_dmdsec_add_id_param_after_init():
    print("Testing adding an id attribute to dmdsec after the element has" +
          " been created...")
    dmd_el = mm.DmdSec()
    dmd_el.ID = 'ie1'
    assert (dmd_el.attrib['ID'] == 'ie1')
Esempio n. 6
0
def test_dmdsec_stub():
    print("Testing the generation of a dmdSec element with an ID attrib...")
    dmd_el = mm.DmdSec(ID='ie1')
    assert (dmd_el.attrib['ID'] == 'ie1')