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