d77d8fe7f1fb8214578bb365a1b5090e5644bff3
[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 from librarian import NoDublinCore
9 from librarian.parser import WLDocument
10 from nose.tools import *
11 from .utils import get_fixture
12
13
14 def test_transform():
15     expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.html')
16
17     html = WLDocument.from_file(
18             get_fixture('text', 'miedzy-nami-nic-nie-bylo.xml')
19         ).as_html().get_bytes()
20
21     assert_equal(html, open(expected_output_file_path, 'rb').read())
22
23
24 @raises(NoDublinCore)
25 def test_no_dublincore():
26     WLDocument.from_file(
27             get_fixture('text', 'asnyk_miedzy_nami_nodc.xml')
28         ).as_html()
29
30
31 def test_passing_parse_dublincore_to_transform():
32     """Passing parse_dublincore=False to transform omits DublinCore parsing."""
33     WLDocument.from_file(
34             get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
35             parse_dublincore=False,
36         ).as_html()
37
38
39 def test_empty():
40     assert not WLDocument.from_bytes(
41             b'<utwor />',
42             parse_dublincore=False,
43         ).as_html()