Stable version 1.2.5.
[librarian.git] / tests / test_text.py
1 # -*- coding: utf-8 -*-
2 from librarian import text, 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.txt')
9
10
11 @with_setup(None, teardown_transform)
12 def test_transform():
13     output_file_path = get_fixture('text', 'asnyk_miedzy_nami.txt')
14     expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_expected.txt')
15     
16     text.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     text.transform(
28         get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
29         get_fixture('text', 'asnyk_miedzy_nami_nodc.txt'),
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     text.transform(
37         get_fixture('text', 'asnyk_miedzy_nami_nodc.xml'),
38         get_fixture('text', 'asnyk_miedzy_nami.txt'),
39         parse_dublincore=False,
40     )
41