720fec6123ad6bbea97ded64f5418f0acafe4594
[librarian.git] / tests / test_epub.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 zipfile import ZipFile
7 from lxml import html
8 from nose.tools import *
9 from librarian import DirDocProvider
10 from librarian.parser import WLDocument
11 from tests.utils import get_fixture
12
13
14 def test_transform():
15     epub = WLDocument.from_file(
16             get_fixture('text', 'asnyk_zbior.xml'),
17             provider=DirDocProvider(get_fixture('text', ''))
18         ).as_epub(flags=['without_fonts']).get_file()
19     zipf = ZipFile(epub)
20
21     # Check contributor list.
22     last = zipf.open('OPS/last.html')
23     tree = html.parse(last)
24     editors_attribution = False
25     for par in tree.findall("//p"):
26         if par.text.startswith(u'Opracowanie redakcyjne i przypisy:'):
27             editors_attribution = True
28             assert_equal(
29                 par.text.rstrip(),
30                 u'Opracowanie redakcyjne i przypisy: '
31                 u'Adam Fikcyjny, Aleksandra Sekuła, Olga Sutkowska.')
32     assert_true(editors_attribution)