1 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
5 from librarian.html import extract_fragments
6 from .utils import get_fixture
9 class FragmentsTest(unittest.TestCase):
12 def test_fragments(self):
13 expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_fragments.html')
15 closed_fragments, open_fragments = extract_fragments(
16 get_fixture('text', 'asnyk_miedzy_nami_expected.legacy.html'))
17 assert not open_fragments
18 fragments_text = "\n\n".join("%s: %s\n%s" % (f.id, f.themes, f) for f in sorted(closed_fragments.values(), key=lambda f: f.id))
19 with open(expected_output_file_path, 'rb') as f:
20 self.assertEqual(fragments_text, f.read().decode('utf-8'))