Python 3.4-3.7 support;
[librarian.git] / tests / test_pdf.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 __future__ import unicode_literals
7
8 import re
9 from tempfile import NamedTemporaryFile
10 from nose.tools import *
11 from librarian import DirDocProvider
12 from librarian.parser import WLDocument
13 from .utils import get_fixture
14
15
16 def test_transform():
17     temp = NamedTemporaryFile(delete=False)
18     temp.close()
19     WLDocument.from_file(
20             get_fixture('text', 'asnyk_zbior.xml'),
21             provider=DirDocProvider(get_fixture('text', ''))
22         ).as_pdf(save_tex=temp.name)
23     tex = open(temp.name, 'rb').read().decode('utf-8')
24
25     # Check contributor list.
26     editors = re.search(r'\\def\\editors\{Opracowanie redakcyjne i przypisy: ([^}]*?)\.\s*\}', tex)
27     assert_equal(editors.group(1), u"Adam Fikcyjny, Aleksandra Sekuła, Olga Sutkowska")