Version 1.3.1dev.
[librarian.git] / tests / test_html.py
1 # -*- coding: utf-8 -*-
2 from librarian import html, NoDublinCore
3 from nose.tools import *
4 from utils import get_fixture, remove_output_file
5
6
7 def teardown_transform():
8     remove_output_file('text', 'asnyk_miedzy_nami.html')
9
10
11 @with_setup(None, teardown_transform)
12 def test_transform():
13     output_file_path = get_fixture('text', 'asnyk_miedzy_nami.html')
14     expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.html')
15     
16     html.transform(
17         get_fixture('text', 'asnyk_miedzy_nami.xml'),
18         output_file_path,
19     )
20     
21     assert_equal(file(output_file_path).read(), file(expected_output_file_path).read())
22
23
24 @with_setup(None, teardown_transform)
25 @raises(NoDublinCore)
26 def test_no_dublincore():
27     html.transform(
28         get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
29         get_fixture('text', 'asnyk_miedzy_nami_nodc.html'),
30     )
31
32
33 @with_setup(None, teardown_transform)
34 def test_passing_parse_dublincore_to_transform():
35     """Passing parse_dublincore=False to transform omits DublinCore parsing."""
36     html.transform(
37         get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
38         get_fixture('text', 'asnyk_miedzy_nami.html'),
39         parse_dublincore=False,
40     )