Ejemplo n.º 1
0
def test_marc21_loader():
    """Test MARC21 loader."""
    COLLECTION = '<collection>{0}{1}</collection>'.format(
        RECORD, RECORD_SIMPLE)

    records = list(load(BytesIO(COLLECTION.encode('utf-8'))))
    assert len(records) == 2
Ejemplo n.º 2
0
def test_marc21_split_stream():
    """Test MARC21 split_stream()."""
    COLLECTION = u'<collection>{0}{1}</collection>'.format(
        RECORD, RECORD_SIMPLE)
    generator = split_stream(BytesIO(COLLECTION.encode('utf-8')))
    assert etree.tostring(next(generator),
                          method='html').decode('utf-8') == RECORD
    assert etree.tostring(next(generator),
                          method='html').decode('utf-8') == RECORD_SIMPLE
Ejemplo n.º 3
0
def test_marc21_records_over_single_line():
    """Test records over single line."""

    records = (u'<record>foo</record>', u'<record>会意字</record>',
               u'<record>&gt;&amp;&lt;</record>')
    collection = u'<collection>{0}</collection>'.format(u''.join(records))

    generator = split_stream(BytesIO(collection.encode('utf-8')))
    for record in records:
        result = etree.tostring(next(generator),
                                encoding='utf-8',
                                method='xml')
        assert record.encode('utf-8') == result