rights info in epub
[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 librarian import html, NoDublinCore
7 from nose.tools import *
8 from utils import get_fixture, remove_output_file
9
10 def teardown_transform():
11     remove_output_file('text', 'asnyk_miedzy_nami.html')
12
13
14 @with_setup(None, teardown_transform)
15 def test_transform():
16     output_file_path = get_fixture('text', 'asnyk_miedzy_nami.html')
17     expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.html')
18
19     html.transform(
20         get_fixture('text', 'asnyk_miedzy_nami.xml'),
21         output_file_path,
22     )
23
24     assert_equal(file(output_file_path).read(), file(expected_output_file_path).read())
25
26
27 @with_setup(None, teardown_transform)
28 @raises(NoDublinCore)
29 def test_no_dublincore():
30     html.transform(
31         get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
32         get_fixture('text', 'asnyk_miedzy_nami_nodc.html'),
33     )
34
35
36 @with_setup(None, teardown_transform)
37 def test_passing_parse_dublincore_to_transform():
38     """Passing parse_dublincore=False to transform omits DublinCore parsing."""
39     html.transform(
40         get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
41         get_fixture('text', 'asnyk_miedzy_nami.html'),
42         parse_dublincore=False,
43     )
44
45 def test_empty():
46     assert html.transform('<utwor />', is_file=False, parse_dublincore=False).find('empty')