3f932390a2a1075ca4ae2cc96526f3e8f81cc5ef
[librarian.git] / tests / test_text.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright © 2008,2009,2010 Fundacja Nowoczesna Polska  
4 #
5 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
6 # For full license text see COPYING or <http://www.gnu.org/licenses/agpl.html>
7 #
8 from librarian import text, NoDublinCore
9 from nose.tools import *
10 from utils import get_fixture, remove_output_file
11
12
13 def teardown_transform():
14     remove_output_file('text', 'asnyk_miedzy_nami.txt')
15
16
17 @with_setup(None, teardown_transform)
18 def test_transform():
19     output_file_path = get_fixture('text', 'asnyk_miedzy_nami.txt')
20     expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.txt')
21     
22     text.transform(
23         get_fixture('text', 'asnyk_miedzy_nami.xml'),
24         output_file_path,
25     )
26     
27     assert_equal(file(output_file_path).read(), file(expected_output_file_path).read())
28
29
30 @with_setup(None, teardown_transform)
31 @raises(NoDublinCore)
32 def test_no_dublincore():
33     text.transform(
34         get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
35         get_fixture('text', 'asnyk_miedzy_nami_nodc.txt'),
36     )
37
38
39 @with_setup(None, teardown_transform)
40 def test_passing_parse_dublincore_to_transform():
41     """Passing parse_dublincore=False to transform omits DublinCore parsing."""
42     text.transform(
43         get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
44         get_fixture('text', 'asnyk_miedzy_nami.txt'),
45         parse_dublincore=False,
46     )
47