bugfix
[librarian.git] / tests / test_ref.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 from unittest import TestCase
5 from librarian.builders import builders
6 from librarian.document import WLDocument
7 from tests.utils import get_fixture
8 from lxml import etree
9
10
11 class RefTests(TestCase):
12     def test_snippet(self):
13         doc = WLDocument(filename=get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml'))
14         doc._compat_assign_section_ids()
15
16         refs = []
17         for ref in doc.references():
18             snippet = ref.get_snippet()
19             b = builders['html']()
20
21             for s in snippet:
22                 s.html_build(b)
23             refs.append(
24                 '\n'.join((
25                     ref.get_link(),
26                     b.output().get_bytes().decode('utf-8')
27                 ))
28             )
29         output = '\n\n'.join(refs)
30         with open(get_fixture('text', 'asnyk_miedzy_nami_refs.html')) as f:
31             self.assertEqual(output, f.read())
32