File: test_utils.py

package info (click to toggle)
python-ebooklib 0.20-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 708 kB
  • sloc: python: 2,541; makefile: 132; sh: 53
file content (36 lines) | stat: -rw-r--r-- 957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from ebooklib import epub, utils


class TestEpubItemInitialization:
    def _create_basic_book(self):
        book = epub.EpubBook()

        book.set_identifier("test123456")
        book.set_title("Test book")
        book.set_language("en")
        book.add_author("Test Author")

        doc1 = epub.EpubHtml(uid="chap_1", file_name="test.xhtml")

        doc2 = epub.EpubHtml(uid="chap_2", file_name="test2.xhtml")

        book.add_item(doc1)
        book.add_item(doc2)

        book.toc = (
            doc1,
            doc2,
        )
        book.add_item(epub.EpubNcx())
        book.add_item(epub.EpubNav())
        book.spine = ["nav", doc1, doc2]

        return book

    def test_pagebreak(self):
        pb = utils.create_pagebreak("page1", label="label", html=True)

        assert pb == (
            '<span xmlns:epub="http://www.idpf.org/2007/ops" epub:type="pagebreak"'
            ' title="page1" id="page1">label</span>'
        )