X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/e9aeedc51047d8d5e9e45c5253c776f8994da965..3a0c83394d5783715fab2be29fa1a9cfc3574e28:/tests/test_ref.py diff --git a/tests/test_ref.py b/tests/test_ref.py new file mode 100644 index 0000000..2383866 --- /dev/null +++ b/tests/test_ref.py @@ -0,0 +1,32 @@ +# This file is part of Librarian, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. +# +from unittest import TestCase +from librarian.builders import builders +from librarian.document import WLDocument +from tests.utils import get_fixture +from lxml import etree + + +class RefTests(TestCase): + def test_snippet(self): + doc = WLDocument(filename=get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')) + doc._compat_assign_section_ids() + + refs = [] + for ref in doc.references(): + snippet = ref.get_snippet() + b = builders['html']() + + for s in snippet: + s.html_build(b) + refs.append( + '\n'.join(( + ref.get_link(), + b.output().get_bytes().decode('utf-8') + )) + ) + output = '\n\n'.join(refs) + with open(get_fixture('text', 'asnyk_miedzy_nami_refs.html')) as f: + self.assertEqual(output, f.read()) +