Fix verse numbering.
[librarian.git] / tests / test_html.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 import io
9 from unittest import TestCase
10 from librarian import NoDublinCore
11 from librarian.parser import WLDocument
12 from nose.tools import *
13 from .utils import get_fixture
14
15
16 class TransformTest(TestCase):
17     maxDiff = None
18
19     def test_transform(self):
20         expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.html')
21
22         html = WLDocument.from_file(
23             get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
24         ).as_html().get_bytes().decode('utf-8')
25
26         self.assertEqual(html, io.open(expected_output_file_path).read())
27
28
29 @raises(NoDublinCore)
30 def test_no_dublincore():
31     WLDocument.from_file(
32             get_fixture('text', 'asnyk_miedzy_nami_nodc.xml')
33         ).as_html()
34
35
36 def test_passing_parse_dublincore_to_transform():
37     """Passing parse_dublincore=False to transform omits DublinCore parsing."""
38     WLDocument.from_file(
39             get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
40             parse_dublincore=False,
41         ).as_html()
42
43
44 def test_empty():
45     assert not WLDocument.from_bytes(
46             b'<utwor />',
47             parse_dublincore=False,
48         ).as_html()