+from librarian.builders import EpubBuilder
+from librarian.document import WLDocument
+from tests.utils import get_fixture
+
+
+class EpubTests(unittest.TestCase):
+ def test_transform(self):
+ epub_file = EpubBuilder().build(
+ WLDocument(
+ get_fixture('text', 'asnyk_zbior.xml'),
+ provider=DirDocProvider(get_fixture('text', ''))
+ )
+ )
+ zipf = ZipFile(epub_file.get_file())
+
+ # Check contributor list.
+ last = zipf.open('EPUB/last.xhtml')
+ tree = html.parse(last)
+ editors_attribution = False
+ for par in tree.findall("//p"):
+ if par.text.startswith('Opracowanie redakcyjne i przypisy:'):
+ editors_attribution = True
+ self.assertEqual(
+ par.text.rstrip(),
+ 'Opracowanie redakcyjne i przypisy: '
+ 'Adam Fikcyjny, Aleksandra Sekuła, Olga Sutkowska.')
+ self.assertTrue(editors_attribution)
+
+ # Check that we have a valid EPUB.
+ self.assertEqual(
+ subprocess.call([
+ 'epubcheck', '-quiet', epub_file.get_filename()
+ ]),
+ 0
+ )
+
+ book = epub.read_epub(epub_file.get_filename())
+
+ # Check that guide items are there.
+ self.assertEqual(
+ book.guide,
+ [
+ {'href': 'cover.xhtml', 'title': 'Okładka', 'type': 'cover'},
+ {'href': 'part1.xhtml', 'title': 'Początek', 'type': 'text'},
+ ]
+ )