Beispiel #1
0
 def test_book_save(self):
     book_001 = epub.Book()
     book_001.load('../geroi_nashego_vremeni.epub')
     paths_to_delete_001 = book_001.clear()
     book_001.save('book_save_test.epub', paths_to_delete_001)
     book_002 = epub.Book()
     book_002.load('book_save_test.epub')
     produced = book_002.get_descr().save()
     expected = read_file('new_meta4.xml')
     self.assertEqual(produced, expected)
Beispiel #2
0
    def test_chapters(self):
        book = epub.Book(self.epub_file)
        self.assertEquals(len(book.chapters), 6)

        for chapter in book.chapters:
            self.assertIsNotNone(chapter)
            self.assertIsInstance(chapter, epub.BookChapter)
Beispiel #3
0
 def test_metadata_contributors(self):
     name = 'Johnson Cave'
     role = 'oth'
     file_as = 'Cave, Johnson'
     self.epub_file.opf.metadata.add_contributor(name, role, file_as)
     book = epub.Book(self.epub_file)
     self.assertIn((name, role, file_as), book.contributors)
Beispiel #4
0
    def __init__(self, filePath, removeFileWhenComplete=False):
        EBookBase.__init__(self, filePath, removeFileWhenComplete)
        self.bookFile = None
        self.book = None

        try:
            self.bookFile = epub.open_epub(self.filePath)
            self.book = epub.Book(self.bookFile)
        except:
            log("EPubEBook: Failed to process eBook %s with error: %s" % (self.filePath, traceback.format_exc()), xbmc.LOGERROR)
Beispiel #5
0
 def test_source(self):
     self.epub_file.opf.metadata.source = 'test_source'
     book = epub.Book(self.epub_file)
     self.assertEquals(book.source, 'test_source')
Beispiel #6
0
 def test_identifiers(self):
     book = epub.Book(self.epub_file)
     self.assertEquals(book.identifiers,
                       [('urn:uuid:477d1a82-a70d-4ee5-a0ff-0dddc60fd2bb',
                         'BookId',
                         'UUID')])
Beispiel #7
0
 def test_dc_format(self):
     self.epub_file.opf.metadata.format = 'test_format'
     book = epub.Book(self.epub_file)
     self.assertEquals(book.dc_format, 'test_format')
Beispiel #8
0
 def test_titles(self):
     title = 'New test title'
     lang = 'fra_alt'
     self.epub_file.opf.metadata.add_title(title, lang)
     book = epub.Book(self.epub_file)
     self.assertIn((title, lang), book.titles)
Beispiel #9
0
 def test_metas(self):
     name = 'meta_name'
     content = 'meta_content'
     self.epub_file.opf.metadata.add_meta(name, content)
     book = epub.Book(self.epub_file)
     self.assertIn((name, content), book.metas)
Beispiel #10
0
 def test_coverage(self):
     self.epub_file.opf.metadata.coverage = 'test_coverage'
     book = epub.Book(self.epub_file)
     self.assertEquals(book.coverage, 'test_coverage')
Beispiel #11
0
 def test_metadata_isbn(self):
     isbn = '7814-54654-4354-43545'
     self.epub_file.opf.metadata.add_identifier(isbn, 'ID_ISBN', 'isbn')
     book = epub.Book(self.epub_file)
     self.assertEquals(book.isbn, isbn)
Beispiel #12
0
 def test_metadata_description(self):
     description = self.epub_file.opf.metadata.description
     book = epub.Book(self.epub_file)
     self.assertEquals(book.description, description)
Beispiel #13
0
 def test_extra_chapters(self):
     book = epub.Book(self.epub_file)
     self.assertEquals(len(list(book.extra_chapters)), 0)
Beispiel #14
0
 def test_book_load(self):
     book = epub.Book()
     book.load('../geroi_nashego_vremeni.epub')
     produced = book.get_descr().save()
     expected = read_file('meta4.xml')
     self.assertEqual(produced, expected)
Beispiel #15
0
 def test_languages(self):
     lang = 'test_lang'
     self.epub_file.opf.metadata.add_language(lang)
     book = epub.Book(self.epub_file)
     self.assertIn(lang, book.languages)
Beispiel #16
0
 def test_relation(self):
     self.epub_file.opf.metadata.relation = 'test_relation'
     book = epub.Book(self.epub_file)
     self.assertEquals(book.relation, 'test_relation')
Beispiel #17
0
 def test_metadata_publisher(self):
     publisher = 'TEST_PUBLISHER'
     self.epub_file.opf.metadata.publisher = publisher
     book = epub.Book(self.epub_file)
     self.assertEquals(book.publisher, publisher)
Beispiel #18
0
 def test_right(self):
     self.epub_file.opf.metadata.right = 'test_right'
     book = epub.Book(self.epub_file)
     self.assertEquals(book.right, 'test_right')
Beispiel #19
0
 def test_dates(self):
     date = '2032-08-04'
     event = 'publication'
     self.epub_file.opf.metadata.add_date(date, event)
     book = epub.Book(self.epub_file)
     self.assertIn((date, event), book.dates)
Beispiel #20
0
 def test_subjects(self):
     title = 'New test subject'
     self.epub_file.opf.metadata.add_subject(title)
     book = epub.Book(self.epub_file)
     self.assertIn(title, book.subjects)
Beispiel #21
0
 def test_dc_type(self):
     self.epub_file.opf.metadata.dc_type = 'test_type'
     book = epub.Book(self.epub_file)
     self.assertEquals(book.dc_type, 'test_type')
Beispiel #22
0
 def setUp(self):
     self.epub_file = epub.open_epub(self.epub_path)
     self.book = epub.Book(self.epub_file)
Beispiel #23
0
def get_book(query):
    book = epub.Book()
    book.load(query['epub_file'][0])
    epub_zip = zipfile.ZipFile(query['epub_file'][0])
    return book, epub_zip