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