1 # -*- coding: utf-8 -*-
3 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 from __future__ import unicode_literals
8 from librarian import NoDublinCore
9 from librarian.parser import WLDocument as LegacyWLDocument
10 from librarian.document import WLDocument
11 from nose.tools import *
12 from .utils import get_fixture
15 def test_transform_legacy():
16 expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.txt')
18 text = LegacyWLDocument.from_file(
19 get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
20 ).as_text().get_bytes()
22 assert_equal(text, open(expected_output_file_path, 'rb').read())
26 expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.txt')
29 filename=get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
30 ).build('txt').get_bytes()
32 assert_equal(text, open(expected_output_file_path, 'rb').read())
35 def test_transform_raw():
36 expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected_raw.txt')
38 text = LegacyWLDocument.from_file(
39 get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
40 ).as_text(flags=['raw-text']).get_bytes()
42 assert_equal(text, open(expected_output_file_path, 'rb').read())
46 def test_no_dublincore():
47 LegacyWLDocument.from_file(
48 get_fixture('text', 'asnyk_miedzy_nami_nodc.xml')
52 def test_passing_parse_dublincore_to_transform():
53 """Passing parse_dublincore=False to the constructor omits DublinCore parsing."""
54 LegacyWLDocument.from_file(
55 get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
56 parse_dublincore=False,