Text converter updated.
[librarian.git] / tests / test_text.py
1 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
3 #
4 import unittest
5 from librarian.builders import builders
6 from librarian.document import WLDocument
7 from .utils import get_fixture
8
9
10 class TextTests(unittest.TestCase):
11     maxDiff = None
12
13     def test_transform(self):
14         expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.txt')
15
16         text = WLDocument(
17             filename=get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
18         ).build(builders['txt']).get_bytes().decode('utf-8')
19
20         with open(expected_output_file_path, 'rb') as f:
21             self.assertEqual(text, f.read().decode('utf-8'))
22
23     
24     def test_transform_raw(self):
25         expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected_raw.txt')
26
27         text = WLDocument(
28             filename=get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
29         ).build(builders['txt'], raw_text=True).get_bytes().decode('utf-8')
30
31         with open(expected_output_file_path, 'rb') as f:
32             self.assertEqual(text, f.read().decode('utf-8'))