-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for kepub conversion and packing
- Loading branch information
Showing
11 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package kepub | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestKepubify(t *testing.T) { | ||
td, err := ioutil.TempDir("", "kepubify") | ||
if err != nil { | ||
assert.FailNow(t, fmt.Sprintf("%v", err), "Could not create temp dir") | ||
} | ||
defer os.RemoveAll(td) | ||
|
||
wd, err := os.Getwd() | ||
if err != nil { | ||
assert.FailNow(t, fmt.Sprintf("%v", err), "Could not get current dir") | ||
} | ||
|
||
kepub := filepath.Join(td, "test1.kepub.epub") | ||
kepubunp := filepath.Join(td, "test1.kepub.epub_unpacked") | ||
|
||
err = Kepubify(filepath.Join(wd, "testdata", "books", "test1.epub"), kepub, false) | ||
assert.Nil(t, err, "should not error when converting book") | ||
assert.True(t, exists(kepub), "converted kepub should exist") | ||
|
||
assert.Nil(t, UnpackEPUB(kepub, kepubunp, true), "should not error when unpacking converted kepub") | ||
assert.True(t, exists(kepubunp), "unpacked kepub dir should exist") | ||
assert.True(t, exists(filepath.Join(kepubunp, "META-INF", "container.xml")), "kepub should have a container.xml") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.gitkeep |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0"?> | ||
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> | ||
<rootfiles> | ||
<rootfile full-path="content.opf" media-type="application/oebps-package+xml"/> | ||
</rootfiles> | ||
</container> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="uuid_id"> | ||
<metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:opf="http://www.idpf.org/2007/opf" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:calibre="http://calibre.kovidgoyal.net/2009/metadata" xmlns:dc="http://purl.org/dc/elements/1.1/"> | ||
<dc:publisher>Patrick G</dc:publisher> | ||
<dc:description><p>This is a test book for <i>kepubify</i>.</p></dc:description> | ||
<meta name="calibre:series" content="Test Series"/> | ||
<meta name="calibre:series_index" content="1"/> | ||
<dc:language>en</dc:language> | ||
<dc:creator opf:role="aut">Patrick G</dc:creator> | ||
<dc:title>epubtool Test Book 1</dc:title> | ||
<meta name="cover" content="cover"/> | ||
<dc:date>2017-07-26T14:00:00+00:00</dc:date> | ||
<dc:identifier id="uuid_id" opf:scheme="uuid">cf8fd6fa-3998-4e25-bfc0-8e9b529f8556</dc:identifier> | ||
</metadata> | ||
<manifest> | ||
<item href="cover.jpeg" id="cover" media-type="image/jpeg"/> | ||
<item href="title.html" id="p0" media-type="application/xhtml+xml"/> | ||
<item href="text01.html" id="p1" media-type="application/xhtml+xml"/> | ||
<item href="toc.ncx" media-type="application/x-dtbncx+xml" id="ncx"/> | ||
</manifest> | ||
<spine toc="ncx"> | ||
<itemref idref="p0"/> | ||
<itemref idref="p1"/> | ||
</spine> | ||
</package> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
application/epub+zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title>kepubify Test Book 1</title> | ||
<meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/> | ||
<style type="text/css"> | ||
@page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; } | ||
</style> | ||
</head> | ||
<body id="p1"> | ||
<div> | ||
<p> | ||
This is the text of a kepubify test book. A symbol: > | ||
</p> | ||
<p> | ||
Lorem ipsum dolor <i>sit</i> amet, consectetur <b><i>adipisicing </i>elit</b>. Molestias reprehenderit sit quaerat dicta doloremque velit impedit, quod minus aliquam fugit quia, pariatur repellat explicabo itaque <b>molestiae. Fugiat </b>consectetur, <a href="title.html">asperiores</a> debitis! | ||
</p> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | ||
<meta name="calibre:cover" content="true"/> | ||
<title>Cover</title> | ||
<style type="text/css" title="override_css"> | ||
@page {padding: 0pt; margin:0pt} | ||
body { text-align: center; padding:0pt; margin: 0pt; } | ||
</style> | ||
</head> | ||
<body id="p0"> | ||
<div> | ||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" height="100%" viewBox="0 0 322 500" preserveAspectRatio="none"> | ||
<image width="322" height="500" xlink:href="cover.jpeg"/> | ||
</svg> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en"> | ||
<head> | ||
<meta content="a22ae125-8044-432d-8b09-98192d0e357c" name="dtb:uid"/> | ||
<meta content="2" name="dtb:depth"/> | ||
<meta content="0" name="dtb:totalPageCount"/> | ||
<meta content="0" name="dtb:maxPageNumber"/> | ||
</head> | ||
<docTitle> | ||
<text>kepubify Test Book 1</text> | ||
</docTitle> | ||
<navMap> | ||
<navPoint class="chapter" id="p0" playOrder="1"> | ||
<navLabel> | ||
<text>Cover</text> | ||
</navLabel> | ||
<content src="title.html"/> | ||
</navPoint> | ||
<navPoint class="chapter" id="p1" playOrder="2"> | ||
<navLabel> | ||
<text>Chapter 1</text> | ||
</navLabel> | ||
<content src="text01.html"/> | ||
</navPoint> | ||
</navMap> | ||
</ncx> |