fixes #2325: repetitions in editor list
[librarian.git] / tests / test_epub.py
index 9fc5637..faa76e7 100644 (file)
@@ -3,14 +3,29 @@
 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
+from zipfile import ZipFile
+from lxml import html
+from nose.tools import *
 from librarian import DirDocProvider
 from librarian.parser import WLDocument
-from nose.tools import *
-from utils import get_fixture
+from tests.utils import get_fixture
 
 
 def test_transform():
-    WLDocument.from_file(
+    epub = WLDocument.from_file(
             get_fixture('text', 'asnyk_zbior.xml'),
             provider=DirDocProvider(get_fixture('text', ''))
-        ).as_epub(flags=['without_fonts'])
+        ).as_epub(flags=['without_fonts']).get_file()
+    zipf = ZipFile(epub)
+
+    # Check contributor list.
+    last = zipf.open('OPS/last.html')
+    tree = html.parse(last)
+    editors_attribution = False
+    for par in tree.findall("//p"):
+        if par.text.startswith(u'Opracowanie redakcyjne i przypisy:'):
+            editors_attribution = True
+            assert_equal(par.text.rstrip(),
+                u'Opracowanie redakcyjne i przypisy: '
+                u'Adam Fikcyjny, Aleksandra Sekuła, Olga Sutkowska.')
+    assert_true(editors_attribution)