Added copyright notice about AGPL. Removed setuputils in favour of plain distutils.
[librarian.git] / tests / test_text.py
1 # -*- coding: utf-8 -*-
2 #
3 #    This file is part of Librarian.
4 #
5 #    Copyright © 2008,2009,2010 Fundacja Nowoczesna Polska <fundacja@nowoczesnapolska.org.pl>
6 #    
7 #    For full list of contributors see AUTHORS file. 
8 #
9 #    This program is free software: you can redistribute it and/or modify
10 #    it under the terms of the GNU Affero General Public License as published by
11 #    the Free Software Foundation, either version 3 of the License, or
12 #    (at your option) any later version.
13 #
14 #    This program is distributed in the hope that it will be useful,
15 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
16 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 #    GNU Affero General Public License for more details.
18 #
19 #    You should have received a copy of the GNU Affero General Public License
20 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 #
22 from librarian import text, NoDublinCore
23 from nose.tools import *
24 from utils import get_fixture, remove_output_file
25
26
27 def teardown_transform():
28     remove_output_file('text', 'asnyk_miedzy_nami.txt')
29
30
31 @with_setup(None, teardown_transform)
32 def test_transform():
33     output_file_path = get_fixture('text', 'asnyk_miedzy_nami.txt')
34     expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.txt')
35     
36     text.transform(
37         get_fixture('text', 'asnyk_miedzy_nami.xml'),
38         output_file_path,
39     )
40     
41     assert_equal(file(output_file_path).read(), file(expected_output_file_path).read())
42
43
44 @with_setup(None, teardown_transform)
45 @raises(NoDublinCore)
46 def test_no_dublincore():
47     text.transform(
48         get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
49         get_fixture('text', 'asnyk_miedzy_nami_nodc.txt'),
50     )
51
52
53 @with_setup(None, teardown_transform)
54 def test_passing_parse_dublincore_to_transform():
55     """Passing parse_dublincore=False to transform omits DublinCore parsing."""
56     text.transform(
57         get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
58         get_fixture('text', 'asnyk_miedzy_nami.txt'),
59         parse_dublincore=False,
60     )
61