Fix XML entities left from MathML.
[librarian.git] / tests / test_text.py
1 # -*- coding: utf-8 -*-
2 #
3 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 #
6 from __future__ import unicode_literals
7
8 from librarian import NoDublinCore
9 from librarian.parser import WLDocument
10 from nose.tools import *
11 from .utils import get_fixture
12
13
14 def test_transform():
15     expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.txt')
16
17     text = WLDocument.from_file(
18             get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
19         ).as_text().get_bytes()
20
21     assert_equal(text, open(expected_output_file_path, 'rb').read())
22
23
24 def test_transform_raw():
25     expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected_raw.txt')
26
27     text = WLDocument.from_file(
28             get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
29         ).as_text(flags=['raw-text']).get_bytes()
30
31     assert_equal(text, open(expected_output_file_path, 'rb').read())
32
33
34 @raises(NoDublinCore)
35 def test_no_dublincore():
36     WLDocument.from_file(
37             get_fixture('text', 'asnyk_miedzy_nami_nodc.xml')
38         ).as_text()
39
40
41 def test_passing_parse_dublincore_to_transform():
42     """Passing parse_dublincore=False to the constructor omits DublinCore parsing."""
43     WLDocument.from_file(
44             get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
45             parse_dublincore=False,
46         ).as_text()