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.builders import builders
10 from librarian.parser import WLDocument as LegacyWLDocument
11 from librarian.document import WLDocument
12 from nose.tools import *
13 from .utils import get_fixture
16 def test_transform_legacy():
17 expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.txt')
19 text = LegacyWLDocument.from_file(
20 get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
21 ).as_text().get_bytes()
23 assert_equal(text, open(expected_output_file_path, 'rb').read())
27 expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.txt')
30 filename=get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
31 ).build(builders['txt']).get_bytes()
33 assert_equal(text, open(expected_output_file_path, 'rb').read())
36 def test_transform_raw():
37 expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected_raw.txt')
39 text = LegacyWLDocument.from_file(
40 get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
41 ).as_text(flags=['raw-text']).get_bytes()
43 assert_equal(text, open(expected_output_file_path, 'rb').read())
47 def test_no_dublincore():
48 LegacyWLDocument.from_file(
49 get_fixture('text', 'asnyk_miedzy_nami_nodc.xml')
53 def test_passing_parse_dublincore_to_transform():
54 """Passing parse_dublincore=False to the constructor omits DublinCore parsing."""
55 LegacyWLDocument.from_file(
56 get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
57 parse_dublincore=False,